我有一个包含来自我的数据库的一些数据的列表。当用户点击列表中的每个项目时,我希望有一个对话框。对话框将在它们之间具有相同的布局,但是从数据库中取出不同的文本。我问题是,我的代码即时获取具有相同内容的对话框。这是我的onClick代码
HotOrNot entry=new HotOrNot(this);
entry.open();
Cursor cursor = entry.getData();
startManagingCursor(cursor);
Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.agonessingle);
dialog.setCancelable(true);
String description2 = DBHelper.DESCRIPTION;
String skord2 = DBHelper.SKOR;
String goala2 = DBHelper.GOALA;
String goalb2 = DBHelper.GOALB;
String title2 = DBHelper.TITLE;
TextView firsttext = (TextView) dialog.findViewById(R.id.firstdialog);
firsttext.setText(title2);
TextView text = (TextView) dialog.findViewById(R.id.TextView1);
text.setText(description2);
TextView text2 = (TextView) dialog.findViewById(R.id.TextView2);
text2.setText(skord2);
TextView text3 = (TextView) dialog.findViewById(R.id.TextView3);
text3.setText(goala2);
TextView text4 = (TextView) dialog.findViewById(R.id.TextView4);
text4.setText(goalb2);
entry.close();
dialog.show();
使用CustomAdapter来完成这项工作会更好吗?请帮忙,我已经在这里堆了好几天了!
答案 0 :(得分:0)
有一个列表,其中包含我数据库中的一些数据。当用户点击列表中的每个项目时,我希望有一个对话框。对话框将在它们之间具有相同的布局,但是从数据库中取出不同的文本。我的问题是我的代码即时获取具有相同内容的对话框。这是我的onClick代码
如果您正在使用onClick,当用户点击时您必须更新Dialog符号,即字符串对象并重置对话框。