Android, Custom ListAdapter get TextView-Text
view
is the list item, so you can do
String s =(String) ((TextView) view.findViewById(R.id.myNr)).getText();
just take reference of of the text view if you extending a BaseAdapter like
Listener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
TextView tx =(TextView)view.findViewById(R.id.text);
String s = tx.getText().toString();
Log.d(TAG, "string : "+s);
I found another way to set an ItemLongClickListener. Therefore I also found a way to get the Text I am displaying.
ListView lv = getListView();
lv.setOnItemLongClickListener(new OnItemLongClickListener(){
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,int row, long arg3) {
String[] tmp = (String[]) arg0.getItemAtPosition(row);
//tmp[0] ist the Text of the first TextView displayed by the clicked ListItem
return true;
}});