Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to extract the text from the selected item on the listView
- ListView lv = (ListView)findViewById(R.id.listView1);
- lv.setAdapter(new ArrayAdapter<Country>(
- this,R.layout.list_black_text,R.id.list_content, values));
- lv.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
- ??????
- }});
- }
- ClassCastException: android.widget.LinearLayout
- ListView lv = (ListView)findViewById(R.id.listView1);
- lv.setAdapter(new ArrayAdapter<Country>(
- this,R.layout.list_black_text,R.id.list_content, values));
- lv.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
- TextView textView = (TextView) view.findViewById(R.id.list_content);
- String text = textView.getText().toString();
- System.out.println("Choosen Country = : " + text);
- }});
- String selectedFromList = (lv.getItemAtPosition(position));
- String s = list.get(position);
- String s = values.get(position).getCountryName();
- Log.e("LISTVIEW", "selected item text = "+s);
- or
- String s = values.get(position).toString();
- Log.e("LISTVIEW", "selected item text = "+s);
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
- TextView textView = (TextView) view.findViewById(R.id.list_content);
- String text = lv.get(position).tostring().trim();
- System.out.println("Choosen Country = : " + text);
- }});
Advertisement
Add Comment
Please, Sign In to add comment