我有一个AutoCompleteTextView,在setOnItemClickListener中, 我想检查用户何时键入特殊文本,AutoCompleteTextView清除并设置为"".但是,当我这样做时,得到一个堆栈溢出错误.通常,setOnItemClickListener中的每个更改都会生成错误!! 我想在我的AutoCompleteTextView中设置一些更改!我怎么能这样做?
通常在文件夹中AutoCompleteTextView填充文件.谁能告诉我如何使用在类中创建的字符串数组来填充?strings.xmlres/valuesAutoCompleteTextView
如何在android中为autocompletetextview提供颜色.我使用这两种颜色作为背景和文字颜色
android:background ="#000000"android:textclolor ="#fffffff".
但问题是如果我在autocompletetextview上键入一些文本,那么可列表值将以白色显示,并且与文本颜色相同.
我无法仅修复整个autocompletetextview的颜色.这该怎么做?
建议请!
提前致谢
我正在尝试将AutoCompleteTextView设置为ListView标头,但如果我这样做,则自动完成框永远不会出现.用于创建自动完成视图的代码直接来自googles docs中的Hello,AutoComplete教程.COUNTRIES阵列也来自那里.
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView myList = (ListView) findViewById(R.id.ResultList);
LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
TableLayout searchHeader = (TableLayout) layoutInflater.inflate(R.layout.search_header, null);
myList.addHeaderView(searchHeader, null, false);
final AutoCompleteTextView textView = (AutoCompleteTextView) myList.findViewById(R.id.edit);
ArrayAdapter<String> searchAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, COUNTRIES);
textView.setAdapter(searchAdapter);
textView.setThreshold(1);
//Dummy data for listview.
String[] listContent = {
"test", "test", "test", "test",
"test", "test", "test", "test"
};
ArrayAdapter<String> adapter = new SearchResultAdapter(this, listContent);
myList.setAdapter(adapter);
}
Run Code Online (Sandbox Code Playgroud)
作为测试,我添加了一个TextChangedListener来尝试强制显示对话框
textView.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, …Run Code Online (Sandbox Code Playgroud) 我在Android中具有自动完成框,我用从服务器检索到的某些列表的名称填充此自动完成框。
假设我有ABC,XYZ,PQR,ABCC,ABCCD等...现在,当我键入AB时首先提出建议:应该给我ABC,ABCC,ABCCD。现在我选择了ABC ..(用;分隔的多值自动完成功能)现在,当我编写ABC时:再次输入ABC,ABCC,ABCCD。
结果我想要:在ABC上,应从自动完成列表中删除选择。所以下一个建议应该是ABCC,只有ABCCD而不是ABC。
请帮帮我
提前致谢..
来自以下注释的代码:
myAutoComplete = (MultiAutoCompleteTextView) findViewById(R.id.talksender);
myAutoComplete.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
myAutoComplete.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, names));
Run Code Online (Sandbox Code Playgroud) 我正在使用谷歌地方autocompletetextview,我按照教程,它工作得很好.到目前为止,我得到了建议结果列表,但没有城市过滤器,大多数建议都是街道名称.
我的问题是,有没有办法过滤街道名称,所以结果列表将只包括城市.
继承我的StringBuilder代码:
HttpURLConnection conn = null;
StringBuilder jsonResults = new StringBuilder();
try {
StringBuilder sb = new StringBuilder(PLACES_API_BASE + TYPE_AUTOCOMPLETE + OUT_JSON);
sb.append("?sensor=false&key=" + API_KEY);
sb.append("&components=country:il");
sb.append("&input=" + URLEncoder.encode(input, "utf8"));
Run Code Online (Sandbox Code Playgroud) 我已经尝试了平常但它不起作用:
multiEdit.requestFocus();
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(multiEdit, InputMethodManager.SHOW_IMPLICIT);
Run Code Online (Sandbox Code Playgroud)
注意我的getActivity().那是因为我MultiAutoCompleteTextView在DialogFragment中使用.片段在里面onCreateView.
keyboard android focus autocompletetextview android-softkeyboard
这是我的AutoCompleteTextView
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="4dp"
android:gravity="center"
android:inputType="textCapWords|textAutoCorrect"
android:textColor="@color/font_autocomplete"
android:textSize="18sp" />
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么设置android:dividerHeight没有效果?
我是Android开发的先驱.
我正在努力自动完成用户输入.我需要谷歌地图,如自动完成用户输入.用户需要从自动完成中选择地址,地点,街道aso,我需要LatLong.
我试图通过使用google cource来完成这项工作,但这不是我想要的.我不想要一个完整的片段或什么东西只用于选择一个地方,我正在寻找一个AutoCompleteTextView解决方案.有这么容易理解的方法吗?
我找到了这个,但这看起来不像这样做的"正常方式"或者我错了吗?这是一个web API调用而不是Android API调用不是吗?
-------------------------------- UPDATE ----------------- ------------
我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="aaeu.app">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-library android:name="com.google.android.maps" />
<application
android:name="com.activeandroid.app.Application"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".presentationlayer.MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".presentationlayer.AlertDetailActivity"
android:screenOrientation="portrait"/>
<meta-data
android:name="AA_DB_NAME"
android:value="local_test_db.db" />
<meta-data
android:name="AA_DB_VERSION"
android:value="9" />
<meta-data
android:name="AA_MODELS"
android:value="aaeu.app.datalayer.Alert , aaeu.app.datalayer.Area" />
<meta-data …Run Code Online (Sandbox Code Playgroud) 我想实现AutocompleteTextView(谷歌地方),但是当我点击片段中的searchView时,片段消失(摔倒).
我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_autocomplete);
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment) getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
.build();
autocompleteFragment.setFilter(typeFilter);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(com.google.android.gms.location.places.Place place) {
// TODO: handle click
}
@Override
public void onError(Status status) {
// TODO: Handle the error.
}
});
}
Run Code Online (Sandbox Code Playgroud)
XML:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="ui.screen.activity.AutocompleteActivity">
<fragment
android:id="@+id/place_autocomplete_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
谢谢你的建议
android google-maps autocompletetextview google-maps-android-api-2