我有一个按钮,如果点击该按钮会打开一个包含呼叫记录列表的警告对话框。但是这样做只显示对话框标题。这是我的代码:
protected void showCustomDialog() {
// TODO Auto-generated method stub
// this method returns the cursor with all call logs.. i've checked the cursor and it is returning.
Cursor curLog = CallLogHelper.getAllCallLogs(getContentResolver());
// it fills the conNames arraylist with its values.
setCallLogs(curLog);
ListView listitems=new ListView(this);
MyAdapter adapter = new MyAdapter( this , R.layout.dialog_list,conNames);
//dialog_list is layout of each item of the list.
alertDialogStores = new AlertDialog.Builder(MainActivity.this)
.setView(listitems)
.setTitle("Stores")
.show();
}
答案 0 :(得分:1)
您需要使用以下代码显示您的日志:
使用下面的代码从arraylist形成字符串,如下所示:
String msg="";
for(int i=0;i<conNames.size();i++)
{msg=msg+" "+conNames;}
alertDialogStores = new AlertDialog.Builder(MainActivity.this)
.setView(listitems)
.setTitle("Stores")
.show();
.setMessage("my logs"+msg);
答案 1 :(得分:1)
写
listitems.setAdapter(adapter);
之后
ListView listitems=new ListView(this);
MyAdapter adapter = new MyAdapter( this , R.layout.dialog_list,conNames);