我正在从数据库中返回这些数据,
@Override
public ArrayList < String > returnProducerData(String entereduser_id) {
Cursor c = db.rawQuery("Select * from producer_table WHERE user_id= "+entereduser_id, null);
ArrayList<String> producerResult = new ArrayList<String>();
int ProducerId = c.getColumnIndex(PRODUCER_ID);
int UserId= c.getColumnIndex(USER_ID);
int ProducerName = c.getColumnIndex(PRODUCER_NAME);
int ProducerSurname = c.getColumnIndex(PRODUCER_SURNAME);
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
producerResult.add(c.getString(ProducerId) +" "+c.getString(UserId) +" "+ c.getString(ProducerName) +" "+ c.getString(ProducerSurname) );
}
return producerResult;
}
我正在使用这种方法在列表视图中显示数据
HashMap<String, String> user = session.getUserDetails();
String user_id= user.get(SessionManager.USER_ID);
ArrayList<String> data = info.returnProducerData(user_id);
//set all data as listview using Array
listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, data));
//set listview action
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
String UserInfo = listView.getItemAtPosition(position).toString();
Intent i =new Intent(ShowProducerTable.this, TestDataBase.class);
i.putExtra("UserInfo", UserInfo);
startActivity(i);
/***just to check if it has value***/
// Toast.makeText(getBaseContext(),"position is : "+position+" and value is "+UserInfo,Toast.LENGTH_SHORT).show();
Toast.makeText(getBaseContext(), id + "", Toast.LENGTH_LONG).show();
}
});
现在我想查看我单击的行的 producer_id。
请你帮助我好吗?