Reputation:
I have one problem in getting the selected string from the ListItems for Eg: consider my ListItem has some elements just consider as one,two,three is present in my taskLit,now if i click on the ListItem i,e on One,Two or Three i should get that Particular String value.Is there any possibility to get the Selected String value from the ListItems or Is there any method like getSelectedStringItem().Thanks in advance.
public void taskOverview()
{
List<TaskList> taskList = new ArrayList<TaskList>();
taskList.add(new TaskList("OutStanding:", true, false));
taskList.add(new TaskList(">>"+TaskList.getOutStandingTask(), false,true));
ListView listView = (ListView) findViewById(R.id.taskList);
listView.setClickable(true);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int arg2,
long arg3) {
// TODO Auto-generated method stub
Intent intent = new Intent(getApplicationContext(), ViewTaskActivity.class);
startActivity(intent);
}
});
TaskListAdapter taskListAdapter = new TaskListAdapter(this, taskList);
listView.setAdapter(taskListAdapter);
taskListAdapter.notifyDataSetChanged();
}
Upvotes: 2
Views: 6007
Reputation: 6318
mListView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
Toast.makeText(getBaseContext(), mListItems.get(position), 1000).show();
}
});
Upvotes: 2