how invoke search for spinner in Android? - android

in may application, i have a spinner widget that contains huge amount of data.
it is hard for user to find his item between them, so i decided to insert search capability for content of spinner.the idea is If the user taps the quick search button he should be provided with a text field to enter a letter and then the spinner list jumps to the fist word it finds with the letter supplied.
is there any solution to that?
thanx

Let us assume, full Spinner data is list.
Initialize
listCurrent=list.clone();
set ArrayAdapter on spinner by
ArrayAdapter<String> adapter=new ArrayAdapter(context, android.R.layout.simple_spinner_item_1, listCurrent);
override onTouch event, open dialog containing edit text say editText and a button on tap, else select item, in dialog button click, get String from editText and filter results and reset adapter by invoking:
listCurrent= filter(list, text);
adapter.notifyDataSetChanged();

Easy way to do things you want is
Have an Button which contain the Text of Selection.
When the Button is clicked Open the Dialog or Activity(startActivityForResult) containing the ListView with EditText.
update the listview with the Searched content in EditText.
When user click on an Item in the ListView. finish the Activity with result.
and update the Text in Button from onActivityResult.

You can use auto-compilation...

Related

Custom Listview with Text and two Images

I am new to Android Development and I am making an application in which I have an EditText and below EditText there is submit Button.
I want that when I write something in EditText and then click submit, the Edittext value will show in Listview with pre defined two Images i.e. their is EditText value in listview and on the right of it two Images also added with that Submit button. These images are Delete and Edit Images so that whenever i click on delete it delete that item and whenever i click on Edit image the EditText value will be ready for editing.
I know that this will be done by getView method and a holder but i could not find any best example for that.
Can anyone provide me the best example for holder and custom listview regarding my application?

Search query from Edittext to Listview row animation

I have a Listview and a Edittext is below the Listview. When user enters something in Edittext and press Send, it is appended as listview row.
When user press Send button, I want the that text should comes from bottom in a animation.
I have no idea where to start. Please help me as I am very new to android animations
To start, use Listview with android:stackFromBottom="true" attribute to stack items from bottom.
And when you click send button, add the edittext data to the arraylist you use for the adapter and then call notifydatasetchanged.
Example:
myarraylist.add("New Item");adapter.notifyDataSetChanged();
For listview item animation refer this: Implementing-Google-Plus-Style-ListView-Animations-on-Android

How to set Select keyword as default Item in Spinner

I have a problem that I have two spinners, second spinner is dependent on first (means when I select a item from 1st Spinner then according to that Second Spinner gets filled). But the problem is, I want Select Keyword as a default Item for both spinners, and when I will click on that, spinner should filled with parsed Info and when I will select an Item from first Spinner then the Parsing starts for Second Spinner but Spinner remains with default Select Keyword, when I will click on second spinner then it should be filled by the parsed Info.
How can I implement this, because when I am setting the adapter in any spinners its onItemSelectedListner first called, which is not desirable.
You will need to add "Select" as your first item in your array list..
and on click event of the Spinner you just remove the First item from your array list
you will also find many similar question in Stack Overflow..search for it and you will get your exact answers with example.
You Can do this by Dialog, make a Customize dialog with List Box and fill the list with parsed data after click on TextBox which contains Select Keyword as a default.

add data from edittext to listview in android

I have an add button, a textbox called edittext, and a listview. When I click the add button data currently in edittext should move to list view. How can I make this happen?
set ArrayAdapter<String> for your
ListView
use insert method of
ArrayAdapter for move string from
EditText to ListView
http://developer.android.com/reference/android/widget/ArrayAdapter.html
"edittext should move to list view".. do you mean focus to be moved to listview OR Editext must disappear and listview must appear?
To handle focus you could use setFocusable() http://developer.android.com/guide/topics/ui/ui-events.html#HandlingFocus
For second option, you could hide widgets in event handlers.
#GSree it is very clear that user569553 wants that when he/she clicks on add button tha data of edittext feild should move to list.
so simply get data using getText() method and the go through this link.
best explanation i have ever found about implementation of getView() and listview.
http://android.amberfog.com/?p=296
If you're using an in-build list adapter such as ArrayAdapter or SimpleAdapter, then all you need to is add the data from EditText.getText() to your data collection, create a NEW list adapter, then when you call setListAdapter() the listview will be refreshed with your new item added.

multi column Custom list view with an editable edit text at the end of the list view

I am on Android 2.1 and I have one multi column Custom listview Using BaseAdapter with an editable edittext at the end of the listview. If the data in the listview do not contain the data of user choice then user should be able to enter data. If the data is already there in the list user will be able to select the data using custom selector. If a selection is made in the list view and user wanted to enter data in the text field at the bottom after selection then the marker in the list view should be unselected. I tried to use onclick() method on edit text using click listener. First time when it is clicked, edit text is getting focus and onclick() method is not fired. And when it is clicked second time, onclick() method is fired and notifyDataSetChanged() method is called. I tried to call the notifyDataSetChanged() method from the Focus Listener, list view selection is gone in my first attempt and edit text is not receiving any data input from the keyboard (frozen).Please help. Thanks, Venkat
Finally I fixed it. notifyDataSetChanged() on focus gained of edittext is recursively calling itself.Hence this issue was there. So, rather than calling notifyDataSetChanged() from focus listener I used a method in the activity to update the list from the focus listener of the edittext. Hence there was no issues of recursion with notifyDataSetChanged().

Categories

Resources