2012-09-17 101 views
0

我正在開發一個android應用程序與ListView使用自定義CursorAdapter從SQLite數據庫檢索數據。適配器的(精簡)代碼在下面提供,問題是在onClick()方法中,pillButton01.setText(Integer.toString(test));行實際上並未更新UI中的按鈕文本,有什麼建議嗎?在此先感謝自定義CursorAdapter setText()不更新android

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; 
     } 

    } 
} 

回答

0

這使得sens。 pillButton01設置爲最後綁定的視圖。 (它一直在改變,你需要找出你在哪個列表項目上,並對這個項目的觀點採取行動

相關問題