我是一名webdeveloper并试图在Android应用程序中使用3个AutoCompleteTextView实现逻辑。我试过一个AutoCompleteTextView,它正常工作。当我有3个AutoCompleteTextView时,它无法正常工作。请帮帮我。
这是我的布局代码。
<AutoCompleteTextView android:id="@+id/textExecutive"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_executive" />
<AutoCompleteTextView android:id="@+id/textSupervisor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_supervisor" />
<AutoCompleteTextView android:id="@+id/textManager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_manager" />
这是在onCreate
textExecutive = (AutoCompleteTextView) findViewById(R.id.textExecutive);
textSupervisor= (AutoCompleteTextView) findViewById(R.id.textSupervisor);
textManager= (AutoCompleteTextView) findViewById(R.id.textManager);
String[] executives = getResources().getStringArray(R.array.executives_array);
String[] supervisors = getResources().getStringArray(R.array.supervisors_array);
String[] managers = getResources().getStringArray(R.array.managers_array);
ArrayAdapter<String> executivesAdapter =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, executives);
ArrayAdapter<String> supervisorsAdapter =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, supervisors);
ArrayAdapter<String> managersAdapter =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, managers);
textExecutive.setAdapter(celebritiesAdapter);
textSupervisor.setAdapter(eventsAdapter);
textManager.setAdapter(itemsAdapter);
答案 0 :(得分:1)
你可以试试,
textExecutive.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View paramView, MotionEvent paramMotionEvent) {
// TODO Auto-generated method stub
textExecutive.showDropDown();
textExecutive.requestFocus();
return false;
}
});
同样做其他两个。