开发者

Is this usage for ArrayAdapter in android is right?

开发者 https://www.devze.com 2023-02-01 02:01 出处:网络
public void onClick(DialogInterface dialog, int which) { setContentView (R.layout.choose); lv1 = (ListView) findViewById(R.id.options);
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

精彩评论

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

关注公众号