1
//code to dislplay item in list view
myList= controller.searchprop(prop_no.getText().toString());
if (myList.size() != 0) {
ListView lv = getListView();
ListAdapter adapter = new SimpleAdapter(Search_Equipments.this, myList,
R.layout.searchview, new String[]{"old_prop", "new_prop", "serial_no", "item_name","responsibility_center"}, new int[]{
R.id.txtsearch_old_prop, R.id.txtsearch_new_prop, R.id.txtsearch_serial_no, R.id.txtsearch_item_name, R.id.txtsearch_center});
setListAdapter(adapter);
InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}else {
Toast.makeText(Search_Equipments.this,"No Records Available, Please enter valid value", Toast.LENGTH_LONG).show();
}
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
HashMap<String,String> map =(HashMap<String,String>)lv.getItemAtPosition(position);
//Cursor c = (Cursor) parent.getItemAtPosition(position);
String prop = map.put(DBController.prop_no1);
//String prop = String.valueOf(parent.getItemAtPosition(position - 1));
Toast.makeText(Search_Equipments.this, prop, Toast.LENGTH_LONG).show();
}
});
有人可以幫助我如何在點擊後從列表視圖中獲取特定數據。或者調試我的代碼。謝謝:) 有人可以幫助如何在點擊後從列表視圖中獲得特定數據。或者調試我的代碼。謝謝:)如何從列表視圖中獲取特定列值點擊該列表視圖中的一行