I'm trying to use the NumberPicker widget in Android 3.1. I figure it is now a standard widget, part of a public API, and not an internal widget anymore.
However, it doesn't work. I can see a textEdit with "0" in it, but there are no buttons, I can't scroll it, and I can't enter a new number with keyboard, either.
Update:
Here's the xml I used for testing:
<NumberPicker
android:id="#+id/numberPicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
By saying doesn't work I mean this: it doesn't have arrows displayed (see the screenshot), and on emulator the keyboard doesn't show up. On a real device it does, but I can't type in the text, I can only erase it.
Any suggestions? I really hate to write my own widget when there is a standard one.
Try to set the values that are possible in the NumberPicker via
setMaxValue setMinValue or setDisplayedValues
maybe the NumberPicker is not working if it doesn't know which values to display.
Related
I have a form in a DialogFragment that includes a spinner. I don't think I can port the spinner options out to a new activity (e.g. customisable ListView etc.) as it will close the DialogFragment, so I'm using the spinner embedded into the DialogFragment (screenshot 1). There is nothing unusual about how I'm populating the spinner with an ArrayList and adapter.
<Spinner
android:id="#+id/breedingcodes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dip" />
Functionally it works fine and the spinner options appear and are selectable, but looks terrible as it only uses half the screen (see screenshot 2), anchored to the position of the spinner in the DialogFragment. Is there anyway to force it to use the full screen, as in the 3rd screenshot with Breeding evidence title? I've tried fiddling with layout_height="match_parent" etc. - no joy.
App is developed for min SDK_10, compiled for SDK_23, build tools 23.0.3.
You can either create your own dialog and style it as you want, or just use
android:spinnerMode="dialog"
as attribute in spinner. See docs here
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
you could try the above in your program to get fullscreen spinner :)
I'm developing an Android application in which I have an EditText control.
I've set the gravity to right, in order to type in Persian.
But when I try to select a text (which is in Persian), the select pointers won't appear.
It works almost fine when the gravity is not set. Also it works fine in other devices like Samsung. But it doesn't work on HTC devices (HTC One xl in my case).
This is my EditText xml
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/txtShare"
android:layout_weight="1"
android:enabled="true"
android:inputType="text|textMultiLine"
android:hint="#string/typeHere"
android:gravity="right"/>
Does anyone know how to fix this?
Edit 1
Also the cursor is always at the beginning of the lines, no matter where I tap in the text.
Edit 2
I'm almost sure that if I can solve the problem in Edit 1, the first problem will be solved along with it. Cause wherever I click in text, the cursor would remain in the beginning of the line
Try adding following attribute to your EditText
android:ellipsize="end"
If you are using right-to-left text you should use the textDirection property for correct support. Gravity only aligns text, so text you enter would still be left-to-right.
The cursor selection is handled in the onTouchEvent method.
I don't have any HTC device, so just an idea.
Maybe you can try to find the problem from the onTouchEvent method.
I have an EditText where I only allow the characters $0123456789.
Everything is working well except when I press the number 4 (on virtual or hardware keyboard) it prints a dollar sign ($).
Why is it doing this?
Here is the XML for my EditText:
<EditText
android:id="#+id/amount_text"
style="#style/textbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#null"
android:cursorVisible="false"
android:digits="$0123456789."
android:gravity="left|center_vertical"
android:hint="#string/amount_hint"
android:inputType="textPhonetic|numberDecimal" />
Secondary question:
mAmountTxt.setKeyListener(DigitsKeyListener.getInstance(false, true));
This achieves what I want (sans $). However, it changes the virtual keyboard to one I don't want. I want the phone keyboard with the big number buttons.
First, I'm 100% sure that it doesn't relate directly to your EditText xml. I have tried your xml in Emu 2.1, Emu 4.0, Emu 4.1 and Real Phone 4.0, and it worked well in each.
Other possible causes:
It might be the emulator - they are sometimes buggy. Can you try to make a new instance of the emulator and test it? Or, try restarting adb?
It might be something programmatic. Do you do any replacing or something like that?
I'm not sure what this does: style="#style/textbox"
Second, to make keyboard layout look like a phone, use this instead of setKeyListener
mAmountTxt.setInputType(InputType.TYPE_CLASS_PHONE);
You wrote:
I want the phone keyboard with the big number buttons.
Set inputType to:
android:inputType="phone"
instead of:
android:inputType="textPhonetic|numberDecimal"
The first time I noticed this was with AlertDialogs putting the entire message on the first line, even when I specified a new line("\n"). On ICS it displays the correct way, but for the life of me, I couldn't get it to work on GB.
Recently I've run into it again. I don't see any reason for it working fine on ICS but not GB and below.
EXAMPLE Project
Heres an example project with a textview, alertdialog, and two standard textviews.
https://github.com/T3hh4xx0r/Text-Example
EDIT
Heres the original question I asked. Seems the problem is more than I originally noticed though.
Android AlertDialog not displaying entire setMessage on certain devices
/EDIT
Here are visual examples of what I mean.
Even specifically setting multiple lines for the textView, the text is still one line, but with extra blank lines below.
Here is the layout that the alertdialog is using to create your view:
<!--
This layout file is used by the AlertDialog when displaying a list of items.
This layout file is inflated and used as the TextView to display individual
items.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/primary_text_light_disable_only"
android:gravity="center_vertical"
android:paddingLeft="14dip"
android:paddingRight="15dip"
android:ellipsize="marquee"
/>
As you can see the ellipsize is set to marquee, so I don't believe it was ever written with the intention to allow multilines.
There is a bug open at the moment that ellipse dots are never shown: http://code.google.com/p/android/issues/detail?id=10554
Therefore it is acting correctly.
If you want it to go onto multiple lines, create your own layout file and pass that to your dialog, that way you have more control anyway.
developing an android app here using API 7. I have an EditText that we use to filter down the list beneath it, so we set the inputType to textFilter so Android wouldn't suggest words or auto-complete.
However, when the user types a character they see the popup box in which they're doing the search shrink. It is clearly getting smaller to make room for the suggestion bar, even though the suggestion bar doesn't actually show.
Using textNoSuggestions instead appears to have the same result. Here is the snippet for the input box:
<EditText
android:id="#+id/search_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:inputType="textFilter"
android:background="#null"/>
Has anyone experienced and overcome this behavior? It doesn't repro on SenseUI, but probably because SenseUI floats the suggestion bar instead of claiming screen real estate for it.
Try textNoSuggestions. I'm not sure what textFilter does, I was hoping to use it to limit input to 0-9 and A-F for a hex keyboard, but found this instead.
The only thing that works consistently in my experience is textVisiblePassword. This both prevents autocorrection and doesn't change the size of the field. Very annoying.