将 AlertBuilder 与游标结合使用
我想要一个 AlertDialog 显示使用光标从数据库中选择的国家/地区列表,它选择 id 和国家/地区名称,我有以下代码,但我不知道如何获取所选项目:
AlertDialog.Builder ab=new AlertDialog.Builder(this);
ab.setTitle(R.string.msg_title_Pais_Resid);
Locale locale = Locale.getDefault();
final Cursor items = DaoProvider.getListaPaisesCursor(this, (locale.getLanguage()).toUpperCase());
ab.setCursor(items,new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Here: get the selected item object (or id)
}
}, Internacionalizacion.colInternacionalizacionTraduccion)
谢谢
I want an AlertDialog to show a list of countries selected from database with a cursor, it selects id and country name, I have the following code but I don't know how to get the selected item:
AlertDialog.Builder ab=new AlertDialog.Builder(this);
ab.setTitle(R.string.msg_title_Pais_Resid);
Locale locale = Locale.getDefault();
final Cursor items = DaoProvider.getListaPaisesCursor(this, (locale.getLanguage()).toUpperCase());
ab.setCursor(items,new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Here: get the selected item object (or id)
}
}, Internacionalizacion.colInternacionalizacionTraduccion)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够执行以下操作:
which
参数是单击的按钮,或者是所选项目的位置(在列表的情况下)。文档位于此处。You should be able to do:
The
which
parameter is either the button that was clicked, or the position of the item that was selected (in the case of a list). Docs are here.