2011-09-02 69 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类不支持该操作。