spinner

How to save spinner to saved/shared preferences

懵懂的女人 提交于 2020-01-25 12:12:20
问题 I am able to save Strings in my saved preferences but having difficulty saving my spinner. public class Diet extends Activity { private SharedPreferences sharedPreferences; Spinner spnCalorieRange; Here is my onCreate: sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String strAge = Integer.toString(age); String strHeight = Integer.toString(height); String strWeight = Integer.toString(weight); name = loadSavedPreference("name"); strAge = loadSavedPreference("strAge");

How to save spinner to saved/shared preferences

两盒软妹~` 提交于 2020-01-25 12:09:08
问题 I am able to save Strings in my saved preferences but having difficulty saving my spinner. public class Diet extends Activity { private SharedPreferences sharedPreferences; Spinner spnCalorieRange; Here is my onCreate: sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String strAge = Integer.toString(age); String strHeight = Integer.toString(height); String strWeight = Integer.toString(weight); name = loadSavedPreference("name"); strAge = loadSavedPreference("strAge");

How to get Spinner inside ListView work in Android?

妖精的绣舞 提交于 2020-01-25 09:12:04
问题 I am developing an app in which I need a ListView whose rows have a TextView, 2 CheckBox and a Spinner. However, I am experiencing issues with onItemSelected() of the Spinner, as it gets called each time it is displayed for each row. In this method I am updating database records with the selected option, but as Android calls it automatically, every time the items get reset because Android calls it with position 0 and this is the value updated in the database. I have read a lot of links about

multiple spinner but one in xml

匆匆过客 提交于 2020-01-25 03:00:37
问题 Hi please look at my xml file, very straight and simple, one textView and one Spinner <TextView android:id="@+id/TextViewContactNamesTexting" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="name" android:layout_width="fill_parent" android:textColor="@color/font" android:textSize="15sp"></TextView> <Spinner android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_marginLeft="10px" android:id="@+id/SpinnerNumTexting"><

Android spinner position and if statements

China☆狼群 提交于 2020-01-24 23:54:27
问题 Having an odd issue here and don't know why it doesn't work, I'm not that used to java yet. to determine the selected item what needs to be done? the spinner has 8 items and 'position' never = 1, or any other number. onItemSelected() is definitely getting fired so is the if statement wrong? public void onItemSelected(AdapterView parent, View v,int position, long id) { if (position == 1) //do something } EDIT: thanks Lion it turns out position doesnt seem to do anything. however, this works.

Spinner with error in Android

十年热恋 提交于 2020-01-24 12:38:28
问题 I'm using a Spinner with the new style Base.Widget.AppCompat.Spinner.Underlined I can see the underline and the line is shown with the accent color while I'm selecting the option. The problem is that I could not find a way to show the error with the red underline like Google does for all its app for the date of birth for example. To see the error try to add a new account in any of the Google apps. It will ask you for the date of birth. Enter an invalid date and then press next. Is there a way

EditText Height Issue

岁酱吖の 提交于 2020-01-23 01:42:47
问题 I am trying to set smaller height of EditText but still have not managed it. Here is my source: <EditText android:layout_width="150dp" android:layout_height="20dp" android:singleLine="true" android:textSize="10dp" /> This code cuts out text and a white rectangular shape appears around EditText control. I have also tried maxHeight/minHeight properties, but did not worked either. If anybody have solved this issue, please help. Or is this is the bug in the android? I can not even resize Spinner,

Spinner in action bar with only icon but not the selected option

前提是你 提交于 2020-01-22 15:00:12
问题 I am working on a app with action bar for navigation. Now I am trying to add a Spinner to the ActionBar . I am able to get my custom icon on the ActionBar . But when I add entries into the spinner, the icon is hidden behind the selection box with first item selected. I want to have only the icon in the ActionBar and the drop-down-list/spinner to appear when tapped on the icon. This is my code : private void initializeMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater

单选按钮触发事件、下拉列表触发事件

偶尔善良 提交于 2020-01-21 22:24:51
OnCheckedChangeListener (处理用户在选中单选按钮的选项时触发)     RadioGroup rg = ( RadioGroup) findById(new OnCheckedChangeListener(){    Public void OnCheckedChanged (RadioGroup group, int checked){ ……    }     }); OnItemSelectedListenerImpl (下拉列表监听器)   1.获得一个下拉列表控件   Spinner spin=(Spinner)findById(R. id. xml文件中Spinner的id);   2.定义一个下拉列表内容适配器   ArrayAdapter<CharSequence> adapter= ArrayAdapter.createFromResource ();   // Adapter . setDropDownViewResource ();//设置列表风格   3.将适配器对象传入spin   spin.setAdapter(adapter);   // 读取下拉框选中内容 String text= 下拉列表对象名.getSelectedItem().toString(); 1 public void onCreate(Bundle

Using spinner as global service

时间秒杀一切 提交于 2020-01-17 11:15:23
问题 I am using the following spinner from the ng2-admin theme: import {Injectable} from '@angular/core'; @Injectable() export class BaThemeSpinner { private _selector:string = 'preloader'; private _element:HTMLElement; constructor() { this._element = document.getElementById(this._selector); } public show():void { this._element.style['display'] = 'block'; } public hide(delay:number = 0):void { setTimeout(() => { this._element.style['display'] = 'none'; }, delay); } } So for each component I have