Reduce amount of spinner items - java

I have a huge sqlite database (round a about 450 entries)
The user has to pick one of those.
Is there a way to create a textinput field which -after 3 characters are entered- turns into a spinner, where the only elements left are the ones with those charakters starting?
I guess i would have to make a View myself, right?
On the other hand i could make a textview above the spinner, and read it out when the user clicks on the spinner, but i wanted to make it "one" element...

Related

Android EditText: Expand upwards

My EditText is expanding downwards when the input has too many characters, which leads to it being hidden behind other elements, like the keyboard. I want the user to be able to see the save and delete buttons which I have layed out below the TextView, even when a long message gets entered.
Is there any way to get the EditText to expand upwards instead of downwards?
For example, in Whatsapp entering long messages leads to the input field expanding upwards and eventually starting to scroll.

Android - how to turn numbers in a TextView into buttons

My utility app requires the user to select a meeting from the calendar, then it removes the non-numerical text, and parses what remains using some logic, with the final aim of identifying two numbers only.
Whenever the app fails to remain with 2 numbers only, I want to open a new activity in which the user will "tell" the app which 2 numbers are the relevant ones.
So I want to display the meeting title, location, and description in 3 TextViews but all numbers should be clickable with a special onClick action that will trigger some methods that handle the identified two numbers...
My question is about how to turn the numbers in the textViews to be clickable and have the special onClick action.
I don't think I can use Linkify as I cannot put an onClickListener on the links.
My only idea now is to turn the numbers into clickable buttons and add the relevant listener to the buttons.
1) Any suggestion on how to do this conversion other than simple step by step parsing?
2) Any better idea than using buttons?
Thanks a million
call setOnClickListener(this) on the TextView and supply a onClick method in your code

Android change textview in recyclerview in all items without redrawing the entire list

I have a recyclerview with a list of items, and each item has, among other things, a textview with a distance from the user. As the user physically moves around I want to update the distances of the items without redrawing the list. For example, assume the user is standing in the middle of a triangle with the points being item1,2,3:
item1 5 feet
item2 10 feet
item3 15 feet
now the user moves 2 feet towards item1 - so it changes to:
item1 3 feet
item2 12 feet
item3 17 feet
but I don't want a redraw. In other words, if the list has 5000 items and the user has scrolled down to item 3150 and then changed his location, I don't want to do something like notifydatasetchanged which will then redraw the entire list and show the user everything from position 0. I want to instead dynamically change only the text for the distance for every item in the list and, as far as the user is concerned, everything is the same and only the distances have changed.
What is the best way of doing this?
First of all, you cannot ovoid list redraw, that is just how it works to update UI but rest assured, there are caches all around to handle small changes.
About items, if you call notifyDataSetChanged RecyclerView will rebind only visible views. So that will be the cost you are paying, the actual size of the adapter (5000 in your example) is irrelevant.
If you want RecyclerView to update only changed views, you have to call notifyItemChanged(position). In that case, RecyclerView will rebind only changed items and only if they are visible.
If you have stable ids, even if you call notifyDataSetChanged, if your adapter has stable ids, RecyclerView will call onBindViewHolder with the existing view holder that currently represents the item at that position. Keep a reference to your item in the ViewHolder. When onBind is called, check if it is the same item and only update necessary parts.

Update TextView numerous times with Buttons

I am making a simple shopping cart application where the user can select items (via buttons) and their running total will be displayed in a text view.
I am fine with having the text view being updated on a single click but I am struggling to figure out how to write my code if the same button is pressed more than once. For example a button writes a value of £3 into the TextView, if this button was clicked again I want the TextView to increase to £6 and so on.
Further to this I want to be able to have more than value added to the TextView from different buttons. I imagine this is more of a Java question as opposed to Android but seeing as I'm a bit of a newbie to both all advice is welcome!
Into your class if you have price value add an incerementPriceValue and make get/set functions for the last one.
If user press the button
setIncrementValue(getIncrementValue()+priceValue);
setText(getIncrementValue+simbolstring);
Create a int variable count and on the click increase the count value and set that value on the textView

Gain edittext focus tapping next in soft keyboard

I have numerous edittexts inside a listview. I want to type in each of the edittexts one by one without having to scroll through the listview. How can I do that?
Use the android:nextFocusDown param to specify which field you'd like to get focus when the user hits the enter key.

Categories