Hi had same problem.

What I suspect you need is an AdapterView.OnItemClickListener. This
captures events when the item is clicked. OnItemSelected appears to
capture when the list item gains focus such as when the DPad buttons
are used to shift focus. Change all your "selected" 's to"click" 's
 and things should be dandy.


On Feb 7, 3:07 pm, androided <[email protected]> wrote:
> I am trying to write an application with a list of items read in from
> a file. This item list and the fields that go with each item are fed
> into a DB. The item names are presented to the user as an auto-
> completing list. Once the list item is selected, I would like to get
> the value from the list and use it to query the database and display
> all the detail information.
>
> The problem I am having is trapping the event usingonItemSelectedListenerand 
> onItemSelected. Below is what I am trying.
>
>         protected void onCreate(Bundle savedInstanceState) {
>             super.onCreate(savedInstanceState);
>             setContentView(R.layout.main);
>
>                 sitedb=(new SiteListSQLiteHelper(this)).getReadableDatabase();
>
>                 model=Site.getAll(sitedb);
>                 startManagingCursor(model);
>
>             sitelistArray=loadsiteArray(model);
>
>            AutoCompleteTextViewtextView = (AutoCompleteTextView)
> findViewById(R.id.autocomplete_site);
>
>             ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
> R.layout.site_list, sitelistArray);
>             textView.setAdapter(adapter);
>             textView.setOnClickListener(onClick);
>             textView.setOnItemSelectedListener(siteSelect);
>         }
>
> I implement the listener:
>
>         private View.OnItemSelectedListener siteSelect=new
> View.OnItemSelectedListener() {
>                 public void siteSelect(View v) {
> // Do some interesting stuff here
>                 }
>         };
>
> This doesn't compile, but it has the fewest syntax errors.
>
> Could someone tell me how to get anOnItemSelectedListenerto work?
> and how I grab the value selected?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to