I'm using the AutoCompleteTextView to allow users to search a from a list of countries. I want to have some default text preloaded in the search bar before the user clicks on it, such as "Search" or "Find Nearest Country". Is it possible to do this? If so how?
Right now, the app opens directly into the search box with the keyboard pulled up. Rather, I want the users to click on the bar before searching.
http://developer.android.com/reference/android/widget/AutoCompleteTextView.html
A TextView's hint seems to be exactly what you need. See android:hint for the XML attribute or setHint() for the corresponding Java method.
To prevent the keyboard from popping as soon as your activity is entered, you should set the android:windowSoftInputMode attribute in the activity declaration to stateHidden.
Related
In the android default search view, 2 clicks are required to input text for search as the first click is used to expand the editText view and another click is to set focus.
It seems to be q redundant and i want to reduce the process to one click only. Is there any methods to do this?
You can change this behavior by calling
setIconifiedByDefault(false)
on your searchView. Setting it to false will show the whole field.
Documentation here.
The two clicks happen if we put the searchView inside a ListView as the searchView lost focus after that. I suspect searchView behave a similar property with editText view in listView.
With reference to
Edit Text in ListActivity ListView loses focus when keyboard comes up
and add the following codes in searchView xml
android:focusable="true"
android:focusableInTouchMode="true"
would get back the normal behavior of the searchView. Hope this will be useful to other people in the future.
How can i get the text selected on one tap from a textview. I want user to have cursor to modify the automatic selection. It's fine if it's easy with edittext, i can make it non-editable.
There shouldn't be any contextual menu. Though there are solutions available but it's not complete and clear. Like when to use spannable, disabling contextual menus.
I wanted to know whether using the SearchView widgit or the EditText widgit with a Button widgit was a better implementation of a search bar I wanted to create (a search bar meaning you type in a word and u click go and it'll take you to some sort of result).
Its depends on your requirement of your database is huge that the hint results cant be displayed in single screen then better to use edit-text with a go button for search.if you have limited data in list-view or something you can use edit search box.
I would like to use ACTION_COLLAPSE_ACTION_VIEW in ActionBar. So I would have search and search suggestions in ActionBar. Is it possible to make show this input text, without need of clicking menu first?
My Activity is only for search purpose so it's not nice when user need first click on search.
I managed to solve my problem by using custom view and displaying there some input field.
I have an OptionMenu which has single option in it named "Search". When the search option is clicked, it should dynamically add a EditText at the top of Activity window like it has in WebView (browser address bar) so users could search something in my application.
After there would be EditBox, one can write inside it. I also want to have some OnTextChanged like event of that EditBox so do you think it's also available with that View?
I made it myself. I added an EditText on the screen with setting as hidden and on button click made it visible. It worked like a charm.