Get Selected String from the ListView
android
Solution
ArrayAdapter<String> adapter;
adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item, profielNames);
setListAdapter(adapter);
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Get the data associated with selected item
Object item = l.getItemAtPosition(position);
String myitem = item.toString();
edittxt.setText("Selected item is :"+ myitem); // You can Set EditText from Here.
}
Problem
I have ListView in my project which has ListItems as in the form of String like this, Complete Task By Today Assign Projects To Developers Meeting Cancelled if click any one of the item from ListView means i want that particular String should be displayed in my EditText(i,e if click meeting cancelled, i need this particular String to display in EditText).Any one guide me,This is how i'm trying to Achieve.enter code here Thanks in advance. final ListView listView = (ListView) findViewById(R.id.taskListDesc); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { ``` @Override public void onItemClick(AdapterView<?> adapter, View view, int selectedItem, long arg3) { System.out.println(adapter.getItemAtPosition(selectedItem)); Intent intent = new Intent(getApplicationContext(), ViewTaskActivity.class); startActivity(intent); } }); } ```