Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>public class Tab2 extends Activity</p> </blockquote> <p><code>Tab2</code> extends Activity, not <code>ListActivity</code>.</p> <p>To get this working, find <code>ListView</code> widget in <code>R.layout.tab2</code>:</p> <pre><code>super.onCreate(savedInstanceState); setContentView(R.layout.tab2); mInflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE); data = new Vector&lt;RowData&gt;(); for (int i = 0; i &lt; title.length; i++) { try { rd = new RowData(i, title[i]); } catch (ParseException e) { e.printStackTrace(); } data.add(rd); } CustomAdapter adapter = new CustomAdapter(this, R.layout.activity_list_view, R.id.title, data); ListView lv = (ListView) findViewById(R.id.your_listiew_id); lv.setAdapter(adapter); lv.setOnItemClickListener(this); </code></pre> <p>Change your class definition to:</p> <pre><code>public class Tab2 extends Activity implements AdapterView.OnItemClickListener { </code></pre> <p>And change <code>onListItemClick(ListView parent, View v, int position, long id)</code> to:</p> <pre><code>@Override public void onItemClick((AdapterView&lt;?&gt; parent, View view, int position, long id) </code></pre> <p>The problem with your code is that you never assign an <code>OnItemClickListener</code> to the <code>ListView</code>. And if you want to use <code>onListItemClick (ListView l, View v, int position, long id)</code>, then <code>Tab2</code> should extend <code>ListActivity</code>, not <code>Activity</code>. To see why: <a href="http://developer.android.com/reference/android/app/ListActivity.html#onListItemClick%28android.widget.ListView,%20android.view.View,%20int,%20long%29" rel="nofollow">Link</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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