自定义游标适配器setText()未更新android
我正在为android开发一个应用程序,它带有一个ListView,使用自定义游标适配器从SQLite数据库检索数据。下面提供了适配器的(缩减)代码,问题是在自定义游标适配器setText()未更新android,android,android-cursoradapter,settext,Android,Android Cursoradapter,Settext,我正在为android开发一个应用程序,它带有一个ListView,使用自定义游标适配器从SQLite数据库检索数据。下面提供了适配器的(缩减)代码,问题是在onClick()方法中,pillButton01.setText(Integer.toString(test))行实际上没有更新UI中的按钮文本,有什么建议吗?提前谢谢 public class PillTrackerAdapter extends CursorAdapter implements OnClickListener {
onClick()
方法中,pillButton01.setText(Integer.toString(test))代码>行实际上没有更新UI中的按钮文本,有什么建议吗?提前谢谢
public class PillTrackerAdapter extends CursorAdapter implements OnClickListener {
@Override
public void bindView(View view, Context context, Cursor cursor)
{
pillButton01 = (Button) view.findViewById(R.id.pillButton1);
pillButton01.setTag(0);
pillButton01.setOnClickListener(this);
}
@Override
public void onClick(View v)
{
int tag = (Integer) v.getTag();
switch(tag) {
case 0: pillButton01.setText(Integer.toString(test));
test++;
break;
}
}
}
这使得sens.pillButton01设置为最后一个绑定视图。(它一直在变化。您需要找出您所处的列表项,并根据此项的视图进行操作