private String mclientName;
コードを oncreate() に入れます
mClientName=new ArrayList<String>();
mClientName.add("abc");
mClientName.add("abc");
mClientName.add("abc");
mClientName.add("abc");
mClientName.add("abc");
((AutoCompleteTextView)findViewById(R.id.etschoolname)).setText(mcollegeName
.equalsIgnoreCase("") ? "" : mcollegeName);
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(UserEditEducationActivity.this, android.R.layout.simple_dropdown_item_1line,mClientName);
((AutoCompleteTextView)findViewById(R.id.etschoolname)).setThreshold(1);
((AutoCompleteTextView)findViewById(R.id.etschoolname)).setAdapter(adapter);
((AutoCompleteTextView)findViewById(R.id.etschoolname)).setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0,
View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),(CharSequence)arg0.getItemAtPosition(arg2), Toast.LENGTH_LONG).show();
}
});
**
およびxml
**
<AutoCompleteTextView
android:id="@+id/etschoolname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header"
android:layout_margin="10dip"
android:hint=""
android:singleLine="true"
android:includeFontPadding="false"
android:maxLength="120"
android:paddingBottom="-10dip" />