2012-07-09 73 views
0

我正在從我的數據庫中檢索數據。在我的數據庫中有一個價值的現場價格。我檢索了數據,我在ListView(其中有TextView)顯示所有數據。我想顯示格式爲Price:67787。但它只顯示67787.我搜索了,但我找不到正確的答案。Android中的顯示部分

+1

你應該張貼您的代碼,因爲它是不可能說什麼不順心。 – Egor 2012-07-09 10:19:08

+0

您將從數據庫中獲得價格的價值,所以將其設置爲textview爲:textview.setText(「Price:」+ value);或者在你已經聲明textview的xml文件中,將它的文本設置爲android:text =「Price:」,並在你的類中設置值 – AkashG 2012-07-09 10:25:06

+0

謝謝AkashG ...我正在使用像這樣的遊標適配器。那麼如何設置值:String [] from = new String [] {db.KEY_INCOME}; int [] to = new int [] {R.id.text1}; SimpleCursorAdapter notes = \t新的SimpleCursorAdapter(this,R.layout.columnview,c,from,to); // System.out.println(「notes =」+ notes.getCount()); // setListAdapter(notes); lv.setAdapter(notes);我該如何設置? – Prakash 2012-07-09 10:28:14

回答

0
String[] from = new String[] { db.KEY_INCOME}; 

Add Followin v v v v v v v v v v v 

for(int i=0; i<from.length; i++) { 

    from[i] = "Price:"+from[i]; 

} 

^^^^^^^^^^^^^^^^^ 

int[] to = new int[] {R.id.text1 }; 

SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.columnview, c, from, to); 

//System.out.println("notes="+notes.getCount()); 

// setListAdapter(notes); lv.setAdapter(notes); 

/* 我想你填寫的TextView的值(內部列表視圖)。 在那裏,你可能已設置

yourTextView.setText(PRICE_FROM_DATABASE); 

而不是設置如下:

yourTextView.setText("Price:"+PRICE_FROM_DATABASE); 

*/

+0

感謝Chintan Raghwani ..我使用這種遊標適配器。那麼我怎樣才能設置值:String [] from = new String [] {db.KEY_INCOME}; int [] to = new int [] {R.id.text1}; SimpleCursorAdapter notes = \t新的SimpleCursorAdapter(this,R.layout.columnview,c,from,to); // System.out.println(「notes =」+ notes.getCount()); // setListAdapter(notes); lv.setAdapter(notes);我該如何設置? – Prakash 2012-07-09 10:30:33

+0

試試我的更新回答 – 2012-07-09 10:39:04

+0

它工作過嗎? – 2012-07-09 10:56:39