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 using
onItemSelectedListener and 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);
AutoCompleteTextView textView = (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 an OnItemSelectedListener to 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