Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid, Custom ListAdapter get TextView-Text
    text
    copied!<p>I coded an own Adapter and added it to my ListActivity via an ListView. The reason why I wrote an own Adapter is, that i had to make some layout changes to the list-entrys. In every entry of the list i've got 3 TextViews.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip"&gt; &lt;TextView android:id="@+id/myNr" android:layout_width="40dip" android:layout_height="fill_parent" android:layout_marginRight="15dip" android:text="id" android:textSize="25dip" android:background="#333333" android:gravity="center_horizontal"/&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_parent"&gt; &lt;TextView android:id="@+id/editor" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_vertical" android:text="Editor: " /&gt; &lt;TextView android:id="@+id/date" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:singleLine="true" android:ellipsize="marquee" android:text="Date: " /&gt; &lt;/LinearLayout&gt; </code></pre> <p></p> <p>The next thing i did, was to implement a "onListItemClick-Methode". Afterwards i implemented a onListItemLongClick - Listener with the following code: </p> <p>in onCreate of the Activity i added:</p> <pre><code> registerForContextMenu(getListView()); </code></pre> <p>then i added the following methode: </p> <pre><code>Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo){ AdapterView.AdapterContextMenuInfo info; info = (AdapterView.AdapterContextMenuInfo) menuInfo; long id = getListAdapter().getItemId(info.position); } </code></pre> <p>where "id" is the index of the item in the list. I now want to get the Text of the texview with the id="myNr of this ListItem. Is there any way get this Text?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload