2011-09-02 27 views
1

我已經嘗試了本網站中討論將數據綁定到TextView的所有示例,但沒有解決我的問題。綁定到TextView

我有一個數據庫,並TextView的,我用一個簡單的鼠標適配器

 MyDataBase mDB = new MyDataBase(this); 
     Cursor cursor = mDB.all(this); 

     String[] from = new String[] {mDB.VALUE}; 
     int[] to = new int[] {R.id.text1View1}; 

     SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.main, cursor, from , to); 
     adapter.setViewBinder(new myViewBinder()); 

,並在這裏一起綁定它們是myViewBinder

public boolean setViewValue(View view, Cursor cursor, int columnIndex) { 

    TextView txtWelcome = (TextView) view; 
    String name = cursor.getString(VALUE_ID); 
    txtWelcome.setText(name); 
} 

的代碼,任何一個可以幫助我瞭解爲什麼午餐時的主要活動沒有變化? 我需要添加哪些額外的代碼?

回答

0

嘗試在設置適配器後添加adapter.notifyDataSetChanged()

0

我相信爲此工作,你必須能夠將SimpleCursorAdapter設置爲TextView上的適配器,但TextView類不支持該操作。