Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement onItemClickListener in List Activity
    text
    copied!<p>following is my ListActivity, onCreate code</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); fakeTripBuilder(); setContentView(R.layout.cutom_list_view); SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.custom_row_view, new String[] {"stop","distance","time","icon","mode"}, new int[] {R.id.text_stop,R.id.text_distance, R.id.text_time, R.id.icon, R.id.text_mode}); populateList(); setListAdapter(adapter); } </code></pre> <p>inside the the same class i have the following method</p> <pre><code> @Override protected void onListItemClick(ListView l, View v, int position, long id){ super.onListItemClick(l, v, position, id); Log.d("Travel","You choosed!"); Object o = this.getListAdapter().getItem(position); Toast.makeText(this, "You Choosed"+o.toString(), Toast.LENGTH_LONG).show(); } </code></pre> <p>and here is the "custom_list_view.xml"</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="wrap_content" android:clickable="false" android:gravity="center_horizontal|center_vertical" android:orientation="vertical" &gt; &lt;ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000fff" android:layout_weight="2" android:drawSelectorOnTop="false"&gt; &lt;/ListView&gt; &lt;TextView android:id="@id/android:empty" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFff00" android:text="No data" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Problem is, onListItemClick method do not call when i click on it. Help !!</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