Reduce the padding inside a spinner android - android

I'm new to android development.Basically my question is how do I change the padding within a spinner so that the text is more compact and can therefore fit more values on the screen.
I have thought about using a slider, however I because there is such a wide range the value could be (1-20000) I wanted to enforce some restriction so selected lower numbers is easier.
Any tips would be great.

You can write s custom Spinner Adapter and override getView to write your own view. I had written some sample code for another similar question which might help.

Related

android: how can i create a TextView combining icom?

is there an easy way to create a text view with an icon inside the text?
like in this number of rates example:
(** 3,45642)
(I have less then reputeshion 10 so I cant insert the image I wanted
** means an icon of a small man)
or is it part of RatingBar that i couldn't find?
I don't want to use android:drawableLeft="#drawable/my_icon"
as i feel like the parenthesis are critical.
Many thanks for any help!
Check out SpannableStringBuilder class.
Usage examples are posted here:
http://www.programcreek.com/java-api-examples/index.php?api=android.text.SpannableStringBuilder

Android Spinners with different Display text from the list values

I'm playing around with Android spinners. I'm not 100% sure if I can get the behavior I want using a spinner, but it's the most obvious choice that comes to mind.
I need something of a dropdown view, the title of which says "x of y selected".
The options in the dropdown would look like:
-All
-None
-Special items only
On clicking one of the dropdown items, the title is reconfigured such that 'x' changes.
It would be ideal to use a spinner, but somehow, it seems that android puts in the first value of the spinner to always be the first values in the list of strings you pass it, and I clearly don't want the title item to be shown in the dropdown list for my case.
Another approach that I came across was to perhaps use a button with a popup with these items in the popup.
Would that be a better approach, or can I actually achieve the behavior using a spinner, or is there another view that would better serve my purpose?
I'm going to redirect to this post, after a lot of searching I found what I was looking for:
How to hide one item in an Android Spinner
The answer by Aebsubis, and make sure to set the text view height to 0. I'll update this answer with more code, once I'm done with tweaking it for my purposes.

Different width between AutoCompleteTextView and suggestions

I have an AutoCompleteTextView item in my app layout. I'd like to reserve just a tiny space for it in the layout, so the user can touch it and begin to write. Instead, I'd like that the list with suggested words that pops up is wider, for example like the entire screen. Actually, the pop-up words list is as wide as the textView.
I've found a simple solution. Attribute android:dropDownWidth. For example, I can set android:dropDownWidth="match_parent". Excuse me for posting a question and then founding the answer immediately after.

Android classic IRC-like chat box

I dread designing UI for Android apps, and I have been searching and trying every possible combination of things to get this the way I want it, but I just cannot seem to get it right.
I want to have a simple Android app that has a text field and a send button next to each other on the bottom of the screen (I already have this correct), and I also want a functional chat area filling the rest of the screen above.
It obviously needs to be scrollable, and I would like to be able to add a new line to the bottom of the chat by doing something like chatBox.add(username, text).
This is the type of view I am looking for:
<bob> my name is bob
<bill> hi bob, my name is bill!
<bob> we are having an awesome conversation, bill
<bill> both of our names start with a b
<bob> how right you are
I had made such app. For chat window I used listView. ListView has stackFromBottom mode. So the last added messages will be on the bottom of ListView. Also I created custom Adapter extending ArrayAdapter, so it is easy to add new messages.
Here is a nice example, how to use listView with adapter and add new items.
Leonisdos is right, you shoud use listView. Do you know the app Irssi-ConnectBot ? I think you should have a look in its source code to have many good examples.
Here the code.google project of Irssi-connectbot (and the github)
Wrap a TextView in a ScrollView. Use append() on the TextView and fullScroll(View.FOCUS_DOWN) on the ScrollView when you append new chat entries.
For longer chats, Leonidos' ListView approach is more efficient, but I thought I'd mention this one.

Backflip Testing Results

Good Morning,
I got my app to install on the Backflip and started testing it. On the emulator everything appeared ok but on the Backflip there are a few notable differences.
I have edittext boxes which on the emulator automatically vary in size to accommodate the text. The text is a number, the max being two digits, i.e., 1-99. On the Backflip the edit boxes seem to be a fixed width and that width is larger than needed. Consequently some of the edittext boxes go past the end of the screen and can't be used or seen. This doesn't happen on the emulator.
I also have spinners. One set of spinners is created using android.R.layout.simple_spinner_dropdown_item populated by an array from array.xml. These spinners have the radio button showing and they work on both the emulator and the Backflip displaying a white background with black text.
The other spinner is created using int layoutID = android.R.layout.simple_spinner_item and is populated with strings from the database using an ArrayAdapter. This spinner displays ok on the emulator with a white background with black text. On the Backflip however, it displays the white background but with white text making the list essentially impossible to see. The list is populated because when I press on an item the background color changes to red, the text is white, and the program works ok.
My question is: Are these discrepancies peculiar to the Backflip or am I doing something wrong in the code? I'd hate to think all devices come with peculiarities that require workarounds. Hopefully I'm doing something wrong and hope someone can point out what it is. I'll post any code someone wants to see but right now I don't know what to post. Thanks.
[Edit] I should add that when I use android.R.layout.simple_spinner_dropdown_item for the other spinner the text shows up ok but I now have the radio buttons which I don't want.
I should add that when I use
android.R.layout.simple_spinner_dropdown_item
for the other spinner the text shows
up ok but I now have the radio buttons
which I don't want.
Do not use android.R.layout.simple_spinner_item for the drop-down item, since that is not what it is supposed to be used for. Use android.R.layout.simple_spinner_dropdown_item, or copy that layout into your project (in data/res/layout/ in one of your SDK platform directories), modify it to suit, and use it.
As to why the behavior difference, Motorola, for the MOTOBLUR handsets, appears to have modified some of the stock resources to fit their needs. While those resources will generally work, they will only have been tested for things they are supposed to be used for. Relying on android.R.layout resources will generally work, but only if those resources are used as intended. If you want full control, make your own copy.

Categories

Resources