Is there no prompt in the Android 4.x spinner anymore? - android

I'm new to Android development and found that I can setup a android:prompt attribute to a Spinner widget. Like so in my layout/my_layout_fragment.xml:
<Spinner
android:id="#+id/boxFunction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_row="14"
android:entries="#array/function_options"
android:gravity="fill_horizontal"
android:prompt="#string/function_prompt" />
I found several screenshots from the Android 2.x epoch which clearly shows the prompt, but I haven't had any luck finding any 4.x screenshots which shows me the prompt. And my compiled app on Android doesn't show it either.
Was the prompt deprecated in 4.x (and if so, where can I get the deprecated information)? Or did I miss something?

I don't think it is deprecated. Maybe from 4.0 it depends on another attribute called
android:spinnerMode
Here is a example which shows you how the prompt works with Spinner Mode attribute.
And before that let me make it clear that,spinnerMode can be set to either dialog or dropdown.
<Spinner android:layout_width="wrap_content"
android:id="#+id/spinner"
android:layout_height="wrap_content"
android:prompt="#string/app_name"
android:spinnerMode="dialog"/>
<Spinner android:layout_width="wrap_content"
android:id="#+id/spinner1"
android:layout_height="wrap_content"
android:prompt="#string/app_name"
android:spinnerMode="dropdown"
android:layout_below="#+id/spinner"
/>
As you can see the first spinner has the spinnerMode set to dialog and the next spinner set to dropdown.
here are the outputs,
Dialog Mode
drop Down
The prompt title I have used here is "Locale Test". Thought I have set it to both the spinners it is visible only in Dialog Mode spinner. So I think it speaks for it.

Related

Change color of Autosuggestbox in Android Studio

I'd like to change the layout and color of the suggestion box I get in my Google Maps-API based app in Android Studio. I have no idea whether I should look into the code of Google Maps or somewhere else.
the link contains an image with the suggestbox I'm talking about
This is the code of the TextView:
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="50dp"
android:layout_toRightOf="#+id/ic_magnify"
android:textSize="15sp"
android:textColor="#ecf0f1"
android:id="#+id/input_search"
android:background="#null"
android:imeOptions="actionSearch"
android:inputType="text"
/>
And I use the PlaceAutocompleteAdapter to autosuggest the possible locations.
Fixed the problem by styling the dropdown popup.
I added android:popupBackground="#2d3e50" to the AutoCompleteTextView-style which changed the color to the one
I needed.

AppCompatCheck Box not visible in android 4.3 API 18

I am using AppCompatCheckBox in XML layout as given below,
<android.support.v7.widget.AppCompatCheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="#+id/checkBox"
android:buttonTint="#color/appColor"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp" />
But the check box is not visible on device running 4.3. But CheckBox text is visible, but not the CheckBox. Whats wrong here?
I am following this link. See the answer with 5 Points.
I don’t know if this solves, but you don’t need to use AppCompatCheckBox; a simple CheckBox is enough.
The activity you are using, presumably an AppCompatActivity, automatically inflates layout checkboxes as AppCompatCheckBoxs.
AppCompat* widgets should be used only when creating views at runtime, e.g. new AppCompatCheckBox(context) or when subclassing.

Android alert dialog not styled properly on Lollipop

I have tried everything to get this working and cannot figure it out.
I am trying to use an alert dialog im my app. It works fine on KitKat but not on Lollipop.
I have even tried using many material dialogs on GitHub and again they work on Kitkat but not on Lollipop.
I am testing on my Nexus 5 with stock nexus factory image.
KITKAT WITH GITHUB MATERIAL DIALOG
KITKAT WITH STOCK ALERT DIALOG
LOLLIPOP WITH GITHUB MATERIAL DIALOG
LOLLIPOP WITH STOCK ALERT DIALOG
Also this is the library on github installed on the same device its not working on. So its something about my app that is causing this. what could it be
android:fitsSystemWindows="true" was the culprit.
I had that declared in my styles.xml.
Removed it from styles.xml and placed in my layout and it working now.
I had the same problem and didn't find any fitsSystemWindows on any of my styles.xml.
To solve it i had to wrap the Layout in a FrameLayout and add the margins to the Layout like this:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/dialog_margin_title"
android:layout_marginBottom="#dimen/dialog_margin"
android:layout_marginLeft="#dimen/dialog_margin"
android:layout_marginStart="#dimen/dialog_margin"
android:layout_marginRight="#dimen/dialog_margin"
android:layout_marginEnd="#dimen/dialog_margin"
android:orientation="vertical">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please enter the email address of the person you would like to follow, this person will be notified." />
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
</LinearLayout>
</FrameLayout>

MvxSpinner Blank on Android 4.0 Only

I have a custom bound MvxSpinner that works great with a ViewModel that's shared between my Android and iOS apps. On Android API Level 15 (4.0.3) and above everything looks great, but on Android API Level 14 (4.0) the spinner displays blank text for each ListItem element. The ListItems are there, but the Text is just blank. When I make a selection on Android 4.0 the proper value is passed back to the ViewModel for the selected item, and my app updates accordingly.
Are there any known bugs with MxvSpinner on Android 4.0?
Here's the XML for my MvxSpinner:
<MvxSpinner
style="#style/spinner_input"
local:MvxItemTemplate="#layout/item_spinner"
local:MvxDropDownItemTemplate="#layout/item_spinnerdropdown"
local:MvxBind="ItemsSource ProductCategoryOptions; SelectedItem SelectedProductCategory" />
And here are my templates:
item_spinner
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:text="Test"
local:MvxBind="Text Caption" />
Item_SpinnerDropDown
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
local:MvxBind="Text Caption" />
Because this question isn't marked as answered yet and I don't know if the answer was found already, I post my solution for reference to future readers.
Place the following code in the file called LinkerPleaseInclude.cs:
public void Include(CheckedTextView checkedText)
{
checkedText.TextChanged += (sender, args) => checkedText.Text = string.Empty + checkedText.Text;
checkedText.Hint = string.Empty + checkedText.Hint;
}
This is necessary for the linker to include the CheckTextView bindings. This works for Android API 16 v4.1.x with linking 'Sdk Assemblies Only' enabled in VS2013.
Are there any known bugs with MvvmCross and custom binding on Android 4.0?
None that I know of - but admittedly I don't test much on 4.0 - my current emulator set includes 2.3.6, 4.0.3, 4.1 and 4.4.2
(I'm also not sure why you call this "custom binding" - I'm assuming this is just using standard MvxBinding and not any additions/customisations)
There are a couple bugs/issues Mvx is currently tracking around MvxSpinner/MvxListView activation and inflation changes in Android 4+ and 4.4 - but neither of these are in the 'invisible' area - see:
https://github.com/MvvmCross/MvvmCross/issues/507
https://github.com/MvvmCross/MvvmCross/issues/481
I'm afraid this isn't an answer to your question/problem. It might be worth trying to use different colors and layouts within your Android v4.0 configuration, and perhaps using the hierarchyviewer to inspect the displayed UI. Looking through questions here there are quite a few comments about spinner visibility in 4.0 (but I couldn't see anything immediately helpful) - https://stackoverflow.com/search?q=spinner+4.0
This appears to be an issue with the local:MvxBind="Text Caption" property not updating properly on the CheckedTextView object.
I changed my Item_SpinnerDropDown.xml to the following ("CheckedTextView" to "TextView") and everything's working now:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto/WIRECOWEBMOB.Droid"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
local:MvxBind="Text Caption" />
This isn't the preferred functionality of the drop-down (lacking the Checked visibility), but it works across all builds now.
Another note: I found this was an issue with Release builds and not a specific Android version. I was working with all of the SDK versions in Debug mode and they worked fine in my emulators, but once I switched to Release the blank drop-down items showed up.
not sure if relevant yet, but it helped me.
I was binding to a list of integers in my MvxSpinner and when I tried to use
local:MvxBind="Text Caption"
in item_spinner.axml and item_spinnerdropdown.axml
The result was a blank space instead of my values. I supposed that it happens because int has no Caption property, so I tried to change the binding so it binds to the object itself, not to it's property. And it is done either so:
local:MvxBind="Text ."
or so:
local:MvxBind="Text"
There's a topic about the difference:
Are "{Binding Path=.}" and "{Binding}" really equal
So, what might help is changing your templates code to:
item_spinner:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:text="Test"
local:MvxBind="Text ." />
Item_SpinnerDropDown:
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
local:MvxBind="Text ." />

Graphical issue with spinner control in Android

My first (old) Android app (Suspension Calculator) is showing a problem I cannot find a solution for: the spinner control on some spinners is showing transparent lines in unwanted places. The pattern is this: every other spinner is having this problem, starting with the first spinner control. So while spinners 2, 4, 6, ... have no unwanted lines, spinners 1, 3, 5, ... have them.
The following image (link below) shows the spinner in selected state first, and in unselected state after the red separator. In selected state, the transparent line is at baseline height for the entire control except some places where the button text can be. It's a little different in unselected state.
I cannot provide an image directly:
[...] as a spam prevention mechanism, new
users aren't allowed to post images.
But I can give you a link:
Screenshot that illustrated the graphical spinner problem
The XML file under res/layout looks like this:
<ScrollView ...>
<TableLayout ...>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/units"
android:gravity="center_vertical"
android:paddingRight="5dp"
/>
<Spinner
android:id="#+id/unit_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
/>
</TableRow>
...
</TableLayout>
</ScrollView>
I see this problem at least since Froyo (Android 2.2). In earlier versions (at least Android 1.6), it wasn't there. It's not there in the Graphical Layout editor in Eclipse, but I see it running the application on the phone and in the emulator - that's at least consistent and hints to a problem I'm causing by not doing things right ;-).
Actually I can reproduce this behavior on Android 2.3. Not possible on Android 2.2 and lower.
It' doesn't matter if you place the Spinner in a TableLayout or RelativeLayout. Same problem there..
Only solution to get ride of the lines was to put a 1px-View between the spinner:
<Spinner android:layout_height="wrap_content" android:id="#+id/spinnerDriver"
android:layout_width="match_parent" android:layout_below="#id/driverDesc" />
<View android:id="#+id/helper" android:layout_height="1px"
android:layout_width="match_parent" android:layout_below="#id/spinnerDriver" />
<Spinner android:layout_height="wrap_content" android:id="#+id/spinnerDriver1"
android:layout_width="match_parent" android:layout_below="#id/helper" />
This is actually a very, very, very... ugly solution but it works for me...

Categories

Resources