Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I put this in a simple example and it works correctly for me. See below:</p> <pre><code>package com.example.autocompletetv; import android.app.ListActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; public class AutoCompleteActivity extends ListActivity { public static final String TAG = AutoCompleteActivity.class.getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_auto_complete); String[] regions = {"One", "Two", "Three", "Four", "Five"}; ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_dropdown_item_1line, regions); this.setListAdapter(adapter); this.getListView().setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { Log.i(TAG, "postion was " + position); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.auto_complete, menu); return true; } } </code></pre> <p>When I click I get:</p> <pre><code>12-09 19:13:30.617: I/AutoCompleteActivity(1883): postion was 2 12-09 19:13:31.997: I/AutoCompleteActivity(1883): postion was 3 12-09 19:13:34.687: I/AutoCompleteActivity(1883): postion was 4 12-09 19:13:37.028: I/AutoCompleteActivity(1883): postion was 0 </code></pre>
 

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