我有一个AutoCompleteTextView根据输入的文本返回地点列表.该AutoCompleteTextView工作正常,返回所需的数据.但是,我面临一个小问题.考虑一下我写 lo的AutoCompleteTextView,然后按一个按钮来搜索匹配的地方.搜索工作正常,并加载AutoCompleteTextView建议位置的下拉列表.但我只能看到下拉,如果我输入第三个字,即lon或我编辑单词为l.我希望下拉列表更新后立即显示下拉列表.
我是android的初学者我试过请帮助我的代码是
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="top"
android:hint="@string/receipt_account_name" >
Run Code Online (Sandbox Code Playgroud)
我尝试使用android:dropDownVerticalOffset ="5dp",android:dropDownHeight ="5dp",android:height ="5dp",android:layout_height ="5dp"等.没有定义字体大小.
在java class adapter = new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line,COUNTRIES);
请帮忙.
我正在开发一个项目,在该项目中我必须访问 SQLite3 数据库中的数据并在键入时向用户显示建议。我已经用 AutoCompleteTextView 尝试过这个,但它不起作用。我正在处理此代码:
ArrayList<String> sugestion = new ArrayList<String>();
public ViewGroup onCreateView (LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState )
{
myAutoComplete = (AutoCompleteTextView) group.findViewById(R.id.searchit);
searchDB = new searchAdapter(getActivity());
searchDB.getWritableDatabase();
myAutoComplete.addTextChangedListener(new TextWatcher(){
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
suggestion = searchDB.getSuggestion(s.toString());
Collections.sort(suggestion);
String[] item = new String[suggestion.size()];
item = suggestion.toArray(item);
for(String word : item)
System.out.println(word);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void …Run Code Online (Sandbox Code Playgroud) java android autocompletetextview android-arrayadapter textwatcher
我正在使用此处提出的问题的代码自动完成textview google places api description - > place_id.我更改了代码以将其添加到我的应用程序中.当我运行代码时,它在我运行代码时给出了以下响应
07-28 11:17:19.244: E/result(350): {"error_message":"This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console: Learn more: https:\/\/code.google.com\/apis\/console","predictions":[],"status":"REQUEST_DENIED"}
Run Code Online (Sandbox Code Playgroud)
我搜索了一些线程,并从下面的线程
我按照建议做了以下步骤.
Places API从控制台启用.Geocoding API从控制台启用.当我运行代码时,它仍然显示上面提到的错误.我是否需要从控制台启用任何其他API.
除此之外,地图工作得很好.如果您想知道这是我在清单中添加的api密钥.
<!-- Goolge Maps API Key Development mode -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAbo3luzbyQTuuPLOyo_Ml***********" />
Run Code Online (Sandbox Code Playgroud)
我正在直接添加服务器密钥以请求URL,如下所示
private ArrayList<String> autocomplete(String input) {
ArrayList<String> resultList = null;
HttpURLConnection conn …Run Code Online (Sandbox Code Playgroud) android autocompletetextview google-geocoding-api google-places-api google-maps-android-api-2
我试图在用户单击 AutoComplateTextView 项目时隐藏软件键盘,但它不起作用。
这是我的代码:
mAutoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
/**
* do something
*/
InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromInputMethod(mAutoCompleteTextView.getWindowToken(), 0);
}
});
Run Code Online (Sandbox Code Playgroud) 我正在制作一个字典应用程序,该数据库包含超过50k字.我AutoCompleteTextView在用户搜索时使用a 来显示单词.我认为加载所有数据并AutoCompleteTextView首先绑定将是一项艰巨的任务,所以我想到了当按键事件发生时加载数据.
为每个按钮按下事件命中数据库也是一个坏主意,因为它很重,所以有没有最佳方法来做到这一点?由于应用程序大小很重要,我不喜欢使用Realm或任何其他数据库.
任何帮助将不胜感激