Android中的显示部件
我正在从数据库中检索数据。在我的数据库中,有一个字段price和value。当我检索到数据时,我在Android中的显示部件,android,Android,我正在从数据库中检索数据。在我的数据库中,有一个字段price和value。当我检索到数据时,我在列表视图中显示所有数据(其中包含文本视图)。我希望显示格式为价格:67787。但它只显示了67787。我搜索了一下,但找不到正确答案 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]
列表视图中显示所有数据(其中包含文本视图
)。我希望显示格式为价格:67787
。但它只显示了67787。我搜索了一下,但找不到正确答案
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);
相反,设置如下:
yourTextView.setText("Price:"+PRICE_FROM_DATABASE);
*/你应该发布你的代码,因为不可能说出哪里出了问题。你将从数据库中获得price的值,因此将其设置为textview.setText(“price:+value”);或者在声明textview的xml文件中,将其文本设置为android:text=“Price:”,并在类中设置值Thank AkashG…我使用的游标适配器如下。那么如何设置值:String[]from=new String[]{db.KEY_INCOME};int[]to=newint[]{R.id.text1};SimpleCursorAdapter notes=新的SimpleCursorAdapter(this,R.layout.columnview,c,from,to);//System.out.println(“notes=“+notes.getCount());//setListAdapter(注释);低压设置适配器(注);我如何设置??谢谢Chintan Raghwani..我正在使用这样的游标适配器。那么我如何设置值:String[]from=new String[]{db.KEY_INCOME};int[]to=newint[]{R.id.text1};SimpleCursorAdapter notes=新的SimpleCursorAdapter(this,R.layout.columnview,c,from,to);//System.out.println(“notes=“+notes.getCount());//setListAdapter(注释);低压设置适配器(注);如何设置?显示一些错误..java.lang.IllegalArgumentException:列'price:price'不存在这是与数据库读取相关的错误,您正在从数据库读取“price:price”列;相反,您必须从数据库中只读“price”。您没有正确实现我的代码。请检查我的代码并与您的代码进行比较。这是更新后我的代码:String[]from=new String[]{db.KEY_INCOME};对于(int i=0;i
yourTextView.setText("Price:"+PRICE_FROM_DATABASE);