spinner

Spinner dropdown list is jumping while scrolling

时光总嘲笑我的痴心妄想 提交于 2019-12-30 06:22:09
问题 Why is my spinner jumping while scrolling? I'm simply doing following: ArrayAdapter<String> adapter = new ArrayAdapter<String>(v.getContext(), layout, textViewId, new ArrayList<String>()); adapter.setDropDownViewResource(layoutDropdown); adapter.addAll(<DATA>); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(listener); As long as the dropdown is small, everything works fine but if it gets larger and scrollable, I see that it jumps around while scrolling. Why? I'm not changing

How do I populate an Android spinner using a JSON web service?

你离开我真会死。 提交于 2019-12-30 05:23:32
问题 How do I parse a JSON file like the one below containing school names and IDs and use the values in the "Name" field to populate the spinner lables? I want the spinner to output the selected SchoolID to the next activity. E.g. So you see "Hill View Elementary" and if you select this the value "HVE" is output to the next activity to act on. { "schools": [ { "Name": "Hill View Elementary", "SchoolID": "HVE"}, { "Name": "Mill View", "SchoolID": "MVE"}, { "Name": "Big School", "SchoolID": "BSC"},

Android- Multiple Spinners

流过昼夜 提交于 2019-12-30 03:13:27
问题 I have this code: package lijap.app.starcraft2counters; import java.io.File; import android.app.Activity; import android.os.Bundle; import android.os.Environment; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; public class Settings extends Activity implements OnItemSelectedListener { Spinner answertime; Spinner gametime;

Can't manage to requestFocus a Spinner

早过忘川 提交于 2019-12-30 03:07:25
问题 I've got an annoying issue with a screen. The screen consists of a bunch of Spinners one under the other, and then underneath the spinner, an EditText. The problem is that when the screen starts, the EditText has focus, meaning that some Spinners are off the top of the screen. Try as I might, I cannot make the top Spinner start focused, either by using <requestFocus/> in the screen XML, or by using requestFocus() in code. I've attempted to do what requestFocus skipping next EditText suggests,

Odd Android Spinner behavior

淺唱寂寞╮ 提交于 2019-12-29 09:38:09
问题 This is the code to populate my spinner. The code: String[] rcs = new String[review_cycles.length]; for (int i = 0; i < review_cycles.length; i++) rcs[i] = review_cycles[i].ReviewCycleName; ArrayAdapter<String> rc_spinnerAdapter = new ArrayAdapter<String>( ActivityManagementReview.this, R.layout.simple_spinner_item, rcs); sp_review_cycle.setAdapter(rc_spinnerAdapter); sp_review_cycle.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?>

Update City Spinner with notifyDataSetChanged after state is selected

…衆ロ難τιáo~ 提交于 2019-12-29 08:40:22
问题 How do I update my city spinner once the user selects a state? Both fields are populated using a DataCall.class that returns JSON data and parses the info into an array for the spinner. My code below sets the city adapter to a defualt "Select State" value and once the user gets selects the state it should use notifyDataSetChanged since the default array for the city spinner is updated with the new city names. The errors I am getting are commented in my code below. public class SearchActivity

Is there a way to use setOnClickListener with an Android Spinner?

一世执手 提交于 2019-12-29 06:58:52
问题 The java.lang.RuntimeException is "Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead," but that is not correct. I am using setOnItemClickListener to do some stuff based on the new selection, but I also need to do some stuff before the user changes the selection. Specifically, I am collecting data for each selection that needs to be saved to a file before moving to another selection, since the other selection is associated with different set of

Can't make spinner's scrollbar always visible (Android)

本秂侑毒 提交于 2019-12-29 06:58:27
问题 I have such a problem - I want to make spinner's scrollbar always visible. But for spinner function setScrollbarFadingEnabled(false); causes crash with a NullExceptionPointer during drawing the GUI. XML tags can't solve this problem too - it seems that spinner just ignore them. Maybe there are another ways to move? For example, using of the custom scrollbar? If yes, how can I do this? Thanks for your answers, Dmitry. As I've been asked, here is LogCat error message for simple project with

How can I add a hint to the Spinner widget? [duplicate]

和自甴很熟 提交于 2019-12-29 06:40:36
问题 This question already has answers here : How to make an Android Spinner with initial text “Select One”? (37 answers) Closed 6 years ago . I have a Spinner in spinnerMode="dropdown" mode. Instead of the preselected first item, I want to show the user a hint, so that there is no default selection (like »Please select an item«) This is the UI I got: and this is the UI I want to achive: I figured that the EditText widget has an android:hint attribute, but not the Spinner widget and setting it

Show dropdown programmatically in ActionBar / ActionBarSherlock

余生颓废 提交于 2019-12-28 13:50:15
问题 I have an activity using ActionBarSherlock with ActionBar.NAVIGATION_MODE_LIST . When entering the page I want the spinner in the action bar to expand programmatically after it's populated with items so the user needs to pick an item. As of now the first item in the adapter is selected automatically. I can't figure out a nice way to expand the spinner in the action bar programmatically. Do I need to use a custom view to achieve this behavior? I've looked on the action bar with the