我正在使用以下代码来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
}
}
请指导我在做什么错误? 任何帮助将不胜感激。
答案 0 :(得分:3)
lst.setAdapter(new ArrayAdapter(this.getcontext(),android.R.layout.simple_list_item_1,items));