我有一个活动页面,其中包含textview字段(name,phoneNo)和一些按钮。我查询数据库以获取单个客户的详细信息(1条记录)。返回一个游标。我想显示此活动的textview中返回的值(name,phoneNo)。如何在不使用listView的情况下执行此操作。我不需要列表,因为只返回一条记录。这就像个人资料页面。但是要使用游标,我想我需要一些listView。这该怎么做 ????提前谢谢
String[] fromColumns = {TakenJobDataBaseOpenHelper.TAKENJOBS_COLUMN_RequestID,TakenJobDataBaseOpenHelper.TAKENJOBS_COLUMN_Destination,TakenJobDataBaseOpenHelper.TAKENJOBS_COLUMN_CustomerName};
int[] toViews = {R.id.textView1, R.id.textView3,R.id.CustomerName};
TakenJobDataBaseOpenHelper jobDatabaseHelper = new TakenJobDataBaseOpenHelper(this);
Cursor cursor = jobDatabaseHelper.getSingleRecord(id);
SimpleCursorAdapter cursoradapter = new SimpleCursorAdapter(this,
R.layout.activity_job_details, cursor, fromColumns, toViews, 0);
答案 0 :(得分:0)
您不必使用列表视图。只需像这样使用它:
if (cursor.moveToFirst()) {
String name = cursor.getString(cursor.getColumnIndex('NAME'));
String phoneNo = cursor.getString(cursor.getColumnIndex('phoneNo'));
((TextView)findViewById(R.id.textView1)).setText(name);
((TextView)findViewById(R.id.textView2)).setText(phoneNo);
} else {
// nothing found!
}