Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
自定义游标适配器setText()未更新android_Android_Android Cursoradapter_Settext - Fatal编程技术网

自定义游标适配器setText()未更新android

自定义游标适配器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 {

我正在为android开发一个应用程序,它带有一个ListView,使用自定义游标适配器从SQLite数据库检索数据。下面提供了适配器的(缩减)代码,问题是在
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设置为最后一个绑定视图。(它一直在变化。您需要找出您所处的列表项,并根据此项的视图进行操作