spinner

Custom ArrayAdapter for a Spinner: drop down view not working properly

丶灬走出姿态 提交于 2019-12-08 03:40:28
问题 I created a custom ArrayAdapter for a Spinner . The difference is, that it shows images from an ArrayList of a complex class instead of plain text. It works so far. The Images and the radio buttons are displayed as desired. The problem is, that the drop down view doesn't behave correctly: it doesn't close on a click and only the radio buttons are clickable instead of the whole view. Does anybody has an idea what's wrong? Do I have to implement some kind of listener in the adapter ?? Here's

Spinner displaying first item text while other item is selected

試著忘記壹切 提交于 2019-12-08 02:32:02
问题 I have a Spinner which is filled by a SimpleCursorAdapter within the onResume() method. The selection is also set in onResume: spinner.setSelection(x) . When I go to another activity and then go back to this activity, the Spinner shows the text of the first item, instead of the text of the selected item. How do I fix this? EDIT: Here's my code: @Override public void onResume(){ super.onResume(); fillSpinner(); } private void fillSpinner() { Db = new DbAdapter(this); Db.open(); final Cursor

How can I get the position of a row in a dataset in order to set the selected item in an Android Spinner?

心已入冬 提交于 2019-12-08 01:32:35
问题 I have a Spinner that's populated using a cursor containing data from a database. It appears that it's impossible to set the selected item in the spinner using the value of the ID column of a row. And that the only way to set the selected item is by using the position of the row within the dataset. Is this correct? If so, is there a more efficient way of determining the row's position than by iterating through the dataset using the cursor? The inefficient (to my mind) way is outlined here.

How to get selected text using android spinner wheel?

不羁岁月 提交于 2019-12-08 01:31:24
I am using Android Spinner Wheel and I already set code for that. AbstractWheel wheelHorizontalView1 = (AbstractWheel) findViewById(R.id.wheelHorizontalView1); NumericWheelAdapter minAdapter = new NumericWheelAdapter(this, 1, 15,"%01d"); minAdapter.setItemResource(R.layout.wheel_text_centered_dark_back); minAdapter.setItemTextResource(R.id.text); wheelHorizontalView1.setViewAdapter(minAdapter); Here is how it looks like: So, my question is how to get 3 as my selected text ? Here is xml if needed, <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android

Getting an enumerated value out of an Android Spinner

纵饮孤独 提交于 2019-12-07 23:58:12
问题 I've written the class below to let me get an enumerated value out of an Android Spinner. There are two lines in getValue() neither of which compile. How should I do this? public class EnumSpinnerListener<T extends Enum> implements AdapterView.OnItemSelectedListener { private String mValue = null; public EnumSpinnerListener(AdapterView<?> adapterView) { adapterView.setOnItemSelectedListener(this); } @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

Spinner showing items as Drop Down List

拟墨画扇 提交于 2019-12-07 22:17:43
问题 I have made a spinner in an activity getting called inside a tab layout. The problem is that the items (3 in nos.) are being showing in a separate dialog as in case of a drop down list and not as a spinner. I followed this example. And as shown the picture I was expecting but I am getting this: & this . I want to show just 3 items inside the spinner and do not want the new dialog for the items to be selected. And I have tried my code both on 2.3.3 and 4.0.3 emulators. Any suggestions? Thanks

自定义Android的Spinner

廉价感情. 提交于 2019-12-07 19:29:40
刚接触Android平台编程不久,被烂教材整得头晕。 有一个关于Spinner扩展的问题,问题是,怎么把弹出来的菜单自定义。当然,书上是没有告诉你的,它们压根就不知道那个和ArrayAdapter相关的两个layout关联到底是什么回事说清楚,就这么列了个代码就算了。我很头晕,于是,写代码,验证自己的推测,搞了好久才“哦”一声解决了自己的疑问。 而自定义Spinner则是和这两个layout有关,ArrayAdapter中初始化的那个layout,是用来渲染spinner被选择的item的样式,而setDropDownResource这个layout,则是弹出框时用的item样式。也就是说,这个spinner使用了两个列表,只不过第一个列表只是显示了一行而已。 下面列个代码,大家仔细看就明白了(因为中午没睡,现在太困了,没精力写为什么了,估计大家能看得懂)。 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dip">

Android: spinner works in Activity but not Fragment

时光怂恿深爱的人放手 提交于 2019-12-07 18:55:01
问题 So I was able to make a Spinner work in a single Activity , but when I transferred the code to a Fragment it obviously didn't work. I am getting an error in these two lines: ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.category_array, android.R.layout.simple_spinner_item); ArrayAdapter<String> adapterItem = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, suggestedItems); and I know that the context this needs to be changed. I already

populate a spinner from database

馋奶兔 提交于 2019-12-07 17:38:27
hi i tried to populate a spinner from DB.... my code: String MY_DATABASE_NAME = "testDB"; String MY_DATABASE_TABLE = "testDBrecords"; TextView resultsView; Spinner spinner; ArrayAdapter<String> adapterForSpinner; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); spinner = (Spinner) findViewById(R.id.spinner); resultsView = (TextView) findViewById(R.id.textview); SQLiteDatabase myDB = null; myDB = this.openOrCreateDatabase(MY_DATABASE_NAME, 1, null); myDB.execSQL(

calling a spinner from another class giving exception

霸气de小男生 提交于 2019-12-07 15:39:28
I have two classes : DineOutActivity.java and Userpersonal .java I HAVE a spinner(spinner1) defined in DineOutActivity.java I am creating a method , so that on image click in UserPersonal.java and calling the spinner method. so as when i click spinner1 from DineOutActivity.java and come to User Personal.java and then click submit it will redirect to another page. here is my DineOutActivity.java public class DineOutActivity extends Activity { Spinner sp; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); /**************