两个或多个 AutoCompleteTextView 不工作
Two or More AutoCompleteTextView are not working
我是一名网络开发人员,正在尝试使用 3 个 AutoCompleteTextView 在 Android 应用程序中实现一个逻辑。我尝试使用一个 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);
你可以试试,
textExecutive.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View paramView, MotionEvent paramMotionEvent) {
// TODO Auto-generated method stub
textExecutive.showDropDown();
textExecutive.requestFocus();
return false;
}
});
其他两个也一样。
我是一名网络开发人员,正在尝试使用 3 个 AutoCompleteTextView 在 Android 应用程序中实现一个逻辑。我尝试使用一个 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);
你可以试试,
textExecutive.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View paramView, MotionEvent paramMotionEvent) {
// TODO Auto-generated method stub
textExecutive.showDropDown();
textExecutive.requestFocus();
return false;
}
});
其他两个也一样。