I am having an identical problem to what was described in this other stackoverflow thread, however after trying out the answers in that thread the problem remains unsolved.
Here's the current situation: I have an application that works for a handheld android device, and we are looking to use it on some larger tablets.
The spinners display properly on the smaller handhelds, but on the tablets the spinner's selected item text will not display. Selecting the dropdown will show the values normally as expected. It is only the closed dropdown that does not show the values.
Changing Font/Background Color does not resolve the issue.
Using adapter.notifyDataSetChanged()
after the dataset updates does not resolve the issue.
I have tried using wrap_content
, 70dp
, and 70sp
for height as well to ensure it isn't a sizing issue
HandHeld Info
- Android Oreo 8.1
Tablet Info
- Samsung Galaxy Tab A (8 inch)
- Android Oreo 8.1
- Nexus Experience 9.5
LinearLayout the Spinner is in:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
Code for Spinner
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mech" />
Spinner Values Assignment:
var response = await this.api.GetMechanics();
var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
foreach (var mech in response.Data)
adapter.Add(mech.code);
this.mySpinner.Adapter = adapter;
App create and usings:
using Android.App;
using Android.Support.V7.App;
using Android.Support.V7.Widget;
using Android.Widget;
using System;
namespace MyProject
{
[Activity(Label = "MyProject", MainLauncher = true, ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait)]
public class Main : AppCompatActivity
{
AppCompatSpinner _mech;
protected override void OnCreate(Android.OS.Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Main);
this._mech = FindViewById<AppCompatSpinner>(Resource.Id.mech);
}
}