开发者

Is this usage for ArrayAdapter in android is right?

public void onClick(DialogInterface dialog, int which) {



                setContentView (R.layout.choose);
                       lv1 = (ListView) findViewById(R.id.options);
                     String[] lv_arr= new String [] {"Book a Classified Ad","Book a Classified display Ad","Book a display Ad","Page Position Availability", "MIS", "Market Share", "Approval", "Upload Material" 开发者_开发百科};
                    ArrayList<String> Options = new ArrayList<String>();  
                    Options.addAll(Arrays.asList(lv_arr));
                    listAdapter = new ArrayAdapter<String>(this, R.layout.choose, R.id.options);  

                    lv1.setAdapter( listAdapter );      

                                      }
           });    

The Error it is giving is "The constructor ArrayAdapter(new DialogInterface.OnClickListener(){}, int, int) is undefined"

I am complete new in programing so please tell me how to change to the list view from Onclicklistner here ?


The this in

ArrayAdapter<String>(this, R.layout.choose, R.id.options);

refers to a DialogInterface.OnClickListener class. ArrayAdapter needs a pointer to an object that extends Context (ie an activity, preferably a listactivity).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜