我正在尝试在我的 android 应用程序中创建一个 AutoCompleteTextView。问题是,我无法自定义它
I'm trying to create an AutoCompleteTextView in my android app. Trouble is, I'm unable to customize it
它适用于以下代码:
AutoCompleteTextView autoTextView = (AutoCompleteTextView) findViewById(R.id.fillText);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, typeAutoFill);
autoTextView.setAdapter(adapter);
//typeAutoFill is my String array that stores the values which must appear.
但是,建议文本的大小对于我的应用来说太大了。我需要让它们变小。我确实查看了此处发布的类似问题..
我试过了:
android:dropDownHeight="" //with different values
这不会产生任何变化。
我还尝试使用 XML 资源文件跟踪 ArrayAdapter,该资源文件仅包含具有我选择的属性的 TextView:
AutoCompleteTextView autoTextView = (AutoCompleteTextView) findViewById(R.id.fillText);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.auto_fill_item,R.id.autoFillTextView,typeAutoFill);
autoTextView.setAdapter(adapter);
这会导致我的应用程序崩溃。
真的被这个问题困住了。我尝试了各种选择。有人可以帮忙吗?
提前致谢。
像这样尝试,为文本制作自定义设计textdesign.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textAutoComplete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#f45455"
android:gravity="center_vertical"
android:padding="5dp" />
你的自动完成
AutoCompleteTextView etChoose= (AutoCompleteTextView) findViewById(R.id.autocomplete);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout. textdesign, ChooseList);
autoTextView.setAdapter(adapter);
只需将 Textsize=10sp 设置为自定义 Textview 或更小
它适用于以下代码:
AutoCompleteTextView autoTextView = (AutoCompleteTextView) findViewById(R.id.fillText);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, typeAutoFill);
autoTextView.setAdapter(adapter);
//typeAutoFill is my String array that stores the values which must appear.
但是,建议文本的大小对于我的应用来说太大了。我需要让它们变小。我确实查看了此处发布的类似问题..
我试过了:
android:dropDownHeight="" //with different values
这不会产生任何变化。
我还尝试使用 XML 资源文件跟踪 ArrayAdapter,该资源文件仅包含具有我选择的属性的 TextView:
AutoCompleteTextView autoTextView = (AutoCompleteTextView) findViewById(R.id.fillText);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.auto_fill_item,R.id.autoFillTextView,typeAutoFill);
autoTextView.setAdapter(adapter);
这会导致我的应用程序崩溃。
真的被这个问题困住了。我尝试了各种选择。有人可以帮忙吗? 提前致谢。
像这样尝试,为文本制作自定义设计textdesign.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textAutoComplete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#f45455"
android:gravity="center_vertical"
android:padding="5dp" />
你的自动完成
AutoCompleteTextView etChoose= (AutoCompleteTextView) findViewById(R.id.autocomplete);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout. textdesign, ChooseList);
autoTextView.setAdapter(adapter);
只需将 Textsize=10sp 设置为自定义 Textview 或更小