Methods Summary |
---|
public AutoCompleteTextView | getTextView()
return mTextView;
|
protected void | onCreate(android.os.Bundle icicle)
// Be sure to call the super class.
super.onCreate(icicle);
// setup layout & views
setContentView(R.layout.autocompletetextview_simple);
mTextView = (AutoCompleteTextView) findViewById(R.id.autocompletetextview1);
// configure callbacks used for monitoring
mTextView.setOnItemClickListener(this);
mTextView.setOnItemSelectedListener(this);
resetItemListeners();
setStringAdapter(5, "a");
|
public void | onItemClick(AdapterView parent, android.view.View view, int position, long id)Implements OnItemClickListener
Log.d(LOG_TAG, "onItemClick() position " + position);
mItemClickCalled = true;
mItemClickPosition = position;
|
public void | onItemSelected(AdapterView parent, android.view.View view, int position, long id)Implements OnItemSelectedListener
Log.d(LOG_TAG, "onItemSelected() position " + position);
mItemSelectedCalled = true;
mItemSelectedPosition = position;
|
public void | onNothingSelected(AdapterView parent)Implements OnItemSelectedListener
Log.d(LOG_TAG, "onNothingSelected()");
mNothingSelectedCalled = true;
|
public void | resetItemListeners()For monitoring OnItemClickListener & OnItemSelectedListener
An alternative here would be to provide a set of pass-through callbacks
mItemClickCalled = false;
mItemClickPosition = -1;
mItemSelectedCalled = false;
mItemSelectedPosition = -1;
mNothingSelectedCalled = false;
|
public void | setStringAdapter(int numSuggestions, java.lang.String prefix)Set the autocomplete data to an adapter containing 0..n strings with a consistent prefix.
// generate the string array
String[] strings = new String[numSuggestions];
for (int i = 0; i < numSuggestions; ++i) {
strings[i] = prefix + String.valueOf(i);
}
// install it with an adapter
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, strings);
mTextView.setAdapter(adapter);
|