我正在插入ListView 3变量,但我只显示2. KEY_NAME和KEY_SUM,它工作正常。我也提出了我不希望用户看到的第三个变量KEY_WIK。如何在用户点击值时获取KEY_WIK?
SimpleAdapter adapter = new SimpleAdapter(getApplicationContext(),
menuItems, android.R.layout.simple_list_item_2,
new String[] { "KEY_NAME", "KEY_SUM", "KEY_WIK" }, new int[] {
android.R.id.text1, android.R.id.text2 });
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
String GName = ((TextView) view.findViewById(android.R.id.text1)).getText().toString();
String GSum = ((TextView) view.findViewById(android.R.id.text2)).getText().toString();
//String GWik = ?
}
});
答案 0 :(得分:-2)
adapter = new SimpleAdapter(getApplicationContext(),
menuItems, android.R.layout.simple_list_item_2,
new String[] { "KEY_NAME", "KEY_SUM", "KEY_WIK" }, new int[] {
android.R.id.text1, android.R.id.text2 });
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
String GWik = arg0.getItemAtPosition(position);
}
});