在对话框内的列表视图上执行 onclick 操作
在我的应用程序中,当我单击显示带有列表视图的对话框的按钮时。项目列表从数组列表中显示。以下是我的代码的一部分
private void album_list_box()
{
Dialog dialog = new Dialog(Nearme_Image_DetailView.this);
AlertDialog.Builder builder = new AlertDialog.Builder(Nearme_Image_DetailView.this);
builder.setTitle("Select the Album Name");
ListView modeList = new ListView(this);
for(int i =0; i< Get_album_name_array.size(); i++)
{
stringArray = Get_album_name_array.get(i);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("fname", stringArray);
listItem.add(map);
}
SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,android.R.layout.simple_list_item_1,new String[] {"fname"}, new int[] {android.R.id.text1});
modeList.setAdapter(listItemAdapter);
builder.setView(modeList);
dialog = builder.create();
dialog.show();
}
这里我正在获取警报框和项目列表,当我单击时我可以获得位置。
但是当单击列表时我想关闭对话框并且我想启动一个异步任务,该怎么做......
in my app when i click a button showing a dialog box with listview. The list of items are been shown from an array list. Following is the bit of my code
private void album_list_box()
{
Dialog dialog = new Dialog(Nearme_Image_DetailView.this);
AlertDialog.Builder builder = new AlertDialog.Builder(Nearme_Image_DetailView.this);
builder.setTitle("Select the Album Name");
ListView modeList = new ListView(this);
for(int i =0; i< Get_album_name_array.size(); i++)
{
stringArray = Get_album_name_array.get(i);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("fname", stringArray);
listItem.add(map);
}
SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,android.R.layout.simple_list_item_1,new String[] {"fname"}, new int[] {android.R.id.text1});
modeList.setAdapter(listItemAdapter);
builder.setView(modeList);
dialog = builder.create();
dialog.show();
}
Here i am a getting the alertbox and list of items, when i click i am able to get the position.
But when the list is clicked i want to close the dialog and i want to start an async Task, how to do this......
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
dialog
声明为类成员,为ListView
设置点击监听器Declare the
dialog
as class member, set up the click listener for theListView