如何在android自定义对话框中设置listview适配器?

时间:2010-05-21 06:33:01

标签: android dialog

我正在使用以下代码来setlistview适配器,但在最后一行给我错误

public class MyCustomDialog extends Dialog 
{
    String[] items= {"lorem", "ipsum", "dolor", "sit", "amet",
            "consectetuer", "adipiscing", "elit", "morbi", "vel",
            "ligula", "vitae", "arcu", "aliquet", "mollis",
            "etiam", "vel", "erat", "placerat", "ante",
            "porttitor", "sodales", "pellentesque", "augue", "purus"};

            TextView selection;


    public MyCustomDialog(Context context) 
    {
        super(context);

    }

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mylistviewdialog);



ListView lst=(ListView)findViewById(R.id.mylist);

        lst.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, items));  

// error here The constructor ArrayAdapter<String>(MyCustomDialog, int, String[]) is undefined



    }

}

请指导我在做什么错误? 任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:3)

lst.setAdapter(new ArrayAdapter(this.getcontext(),android.R.layout.simple_list_item_1,items));