spinner

Android Spinner selection

痴心易碎 提交于 2019-12-17 15:36:32
问题 The OnItemSelectedListener event handler gets called both when a spinner selection is changed programmatically, and when a user physically clicks the spinner control. Is is possible to determine if an event was triggered by a user selection somehow? Or is there another way to handle spinner user selections? 回答1: To workaround you need to remember the last selected position. Then inside of your spinner listener compare the last selected position with the new one. If they are different, then

Android Spinner - How to make dropdown view transparent?

ε祈祈猫儿з 提交于 2019-12-17 11:02:01
问题 I have a custom spinner dropdown xml file in /res/layout/: spinner_view_dropdown.xml: <?xml version="1.0" encoding="UTF-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/spinner_item_dropdown" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/transparent" style="@style/spinner_item_dropdown" /> I'm setting the spinner dropdown via java: // "Spinner", aka breadcrumbs Spinner spin = (Spinner)

Android Spinner - How to make dropdown view transparent?

别等时光非礼了梦想. 提交于 2019-12-17 11:01:56
问题 I have a custom spinner dropdown xml file in /res/layout/: spinner_view_dropdown.xml: <?xml version="1.0" encoding="UTF-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/spinner_item_dropdown" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/transparent" style="@style/spinner_item_dropdown" /> I'm setting the spinner dropdown via java: // "Spinner", aka breadcrumbs Spinner spin = (Spinner)

Android: Where is the Spinner widget's text color attribute hiding?

僤鯓⒐⒋嵵緔 提交于 2019-12-17 02:58:53
问题 I'm trying to change the text color of the single item that is displayed in the spinner button after you select an item from the dropdown. I've been perusing the themes.xml and styles.xml in the Android SDK for an hour now, and I can't seem to find where the Spinner is getting the color value from. To clarify, I'm NOT trying to change the color of a dropdown item, I'm trying to change the color of the spinner's displayed text when there is no dropdown. I guess you could call it the spinner's

How to get Spinner value?

核能气质少年 提交于 2019-12-17 02:26:32
问题 In Android, I am trying to get the selected Spinner value with a listener. What is the best way to get the spinner's value? 回答1: Spinner mySpinner = (Spinner) findViewById(R.id.your_spinner); String text = mySpinner.getSelectedItem().toString(); 回答2: The Spinner should fire an "OnItemSelected" event when something is selected: spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { Object

Android--UI之Spinner

ε祈祈猫儿з 提交于 2019-12-17 00:51:19
前言   最近一直在讲AndroidUI的开发,今天讲一下Spinner控件,这是一个列表选择框,可以弹出一个列表供用户选择。在本片博客中,会讲解Spinner的基本属性以及设置之后的效果,以及使用SimpleAdapter绑定自定义格式的数据到Spinner中。 Spinner    Spinner 是一个列表选择框,会在用户选择后,展示一个列表供用户进行选择。Spinner是ViewGroup的间接子类,它和其他的Android控件一样,数据需要使用Adapter进行封装。   下面介绍一下Spinner的常用XML属性,Android也为其属性提供了相应的getter、setter方法: android:spinnerMode:列表显示的模式,有两个选择,为弹出列表(dialog)以及下拉列表(dropdown),如果不特别设置,为下拉列表。。 android:entries:使用<string-array.../>资源配置数据源。 android:prompt:对当前下拉列表设置标题,仅在dialog模式下有效。传递一个“@string/name”资源,需要在需要在资源文件中定义<string.../>。   作为一个列表选择控件,Spinner具有一些选中选项可以触发的事件,但它本身没有定义这些事件,均继承自间接父类 AdapterView

Spinner does not apply dropDownSelector attribute

流过昼夜 提交于 2019-12-14 04:16:10
问题 I'm using spinner and want to add spinner - to change behavior depends of states(focused, pressed) sample project is here https://github.com/vovs/spinner_issue My code: activity_main.xml <Spinner android:id="@+id/spinner" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="30dp" android:spinnerMode="dropdown" android:dropDownSelector="@drawable/spinner_state" /> spinner

How to return the id of selected item of listview

浪尽此生 提交于 2019-12-14 04:10:35
问题 Hello friends i am new to android and i am learning about android programming. I am working with my friends. I have web service from which i am showing list of cities in listview now my friend give me task that is when i will click on city then id of that city return me so i don't how to do so please anybody can help me to do so. public class CityNameActivity extends ListActivity{ private TextView displayText; ListView list; private ProgressDialog pDialog; // URL to get Cities JSON private

How to dynamically change the text box value according to the recently selected spinner value?

送分小仙女□ 提交于 2019-12-14 03:28:48
问题 Here is screenshot ...my changes in spinner value reflects only after 2 swipes I have an app with 10 screens and i have 1 spinner in my main activity and a textbox in fragment .I want to display the recently selected spinner value in my textbox . I wrote a code to display the selected spinner value in my text box and its become stable throughout all my screens.But i don't know how to dynamically change the text box value according to the recently selected spinner value. ( Before downvoting

Json data array request keeps skipping onResponse

北战南征 提交于 2019-12-14 02:29:24
问题 I keep trying to look up and find a solution for my problem. I am populating a Spinner with json data from a URL , the Json data is nameless and I'm trying to get the data into an ArrayList so I can populate the Spinner . Whenever I debug I can see that it skips my onResponse() method after making either StringRequest or JSONArrayRequest , Please look at my code and see what am I doing wrong yearsp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void