spinner

Adding OnItemSelectedListener to Spinner

亡梦爱人 提交于 2019-12-10 15:51:42
问题 I have a button and a spinner (originally hidden). When user presses a button, spinner gets populated with items and becomes visible. Now I would like to add OnItemSelectedListener to the spinner. and I have tried many tutorials with no luck. This is my OnCreate function public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button load_routes = (Button)findViewById(R.id.load_routes); Spinner routes = (Spinner)findViewById(R.id

Android- Data is allocated in spinner but when selected not showing the value in spinner

爱⌒轻易说出口 提交于 2019-12-10 15:42:52
问题 Problem I am fetching some product category from mysql using Retrofit. The data is coming and allocated in spinner but when I select an item its not displayed. In the drop down menu the items are allocated and the setOnItemSelected listener is also working. But the selected item not showing up in the spinner. I have tried almost everything also related stackoverflow questions but not working. Pls help me. Thanks in advance. Code This is the OrderActivity public class OrderActivity extends

Android: Custom Adapter with custom spinner drop down xml layout giving error

邮差的信 提交于 2019-12-10 14:54:35
问题 I have a spinner with a custom adapter that I used to set the height of the first element in the spinner drop down to zero. I do this to have a default message in my spinner (first element) without the user being able to click it, since it's not visible. package org.digitalhealthagency.elaj.util; import java.util.ArrayList; import org.digitalhealthagency.elaj.gui.R; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;

Action Bar .selectTab() and .setSelectedNavigationItem() not working

社会主义新天地 提交于 2019-12-10 12:23:50
问题 I have an ActionBar with multiple tabs, each linked to a fragment. The problem I have is that when I use either bar.selectTab(Tab) or bar.setSelectedNavigationItem(int) , it doesn't work. Specifically, this problem occurs when the tabs get reduced down to a Spinner in the ActionBar. 回答1: There is a known bug with the ActionBar, specifically with the methods mentioned above and specifically when the ActionBar's tabs are reduced to a Spinner. Here's my workaround. It uses reflection to drill

Save Spinner with SharedPreferences in fragment (OnItemSelectedListener)

流过昼夜 提交于 2019-12-10 11:56:49
问题 I am new to Android programming and at the moment I am trying to make some spinners with four array elements (string-array), and then save the current state with shared preferences. I've already done a lot of research, but most of the solutions only work for activities, and I am working in a fragment. The code now is as follows: FragmentSection3.java public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); View v =

how to delete the particular selected item from the list of items in spinner

别等时光非礼了梦想. 提交于 2019-12-10 11:55:33
问题 I followed http://www.designerandroid.com/?p=8 this one to add the values in the spinner.In it while we select the "clear spinner items" the whole events are will be delete. But i need to the selected particular item only want to delete.Any one can help me.. The sample code will help to me lot. 回答1: To delete particular item from spinner you have to remove it from arrayadapter which you are using for filling it. So first get the position of item you are wanting to delete. Then get the object

Android Spinners, say I pull spinner selections from SQL, can I also add their SQL _id's to the spinner values?

天涯浪子 提交于 2019-12-10 11:47:24
问题 I query my SQL database to populate my spinners, I have no problem populating the spinner with a string array of the resulting Book Titles (this is a library style app). While getting the Book Titles into the spinner for selection is no problem, what is the best way to tie these titles back to their SQL _id's? I've been looking for a way to make spinners "multi-dimensional" but so far I don't see how. Any help in the right direction would be much appreciated, thank you! 回答1: You definitely

Android Kotlin pass spinner values to mutable list

二次信任 提交于 2019-12-10 11:37:59
问题 I have an application with a spinner that contains several items. I created it and all that Could anyone give me an example of how I can pass these values to a list I have? Using a mutableList? Cheers class NewKitListActivity : AppCompatActivity() { var spinnerArray = arrayOf("Dumbell", "Punching Bag", "Yoga Ball", "Skipping Rope") val kitMutableList = mutableListOf(spinnerArray) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout

Spinner with custom text font and color

空扰寡人 提交于 2019-12-10 11:09:40
问题 I want to use custom font and color in Spinner. I can't modify them directly in <spinner/> Here's my code <Spinner android:id="@+id/spinner2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="5pt" android:layout_marginTop="5pt" android:backgroundTint="#d9d9d9" android:entries="@array/dropdown_main" /> It should look like this: Text font is Product Sans Bold, color is #333333 回答1: Here you can make a custom xml file in layout folder where you

Android 2.2 - how do i set an spinner's alpha property?

删除回忆录丶 提交于 2019-12-10 10:54:20
问题 I'm trying to make a spinner totally transparent. In Android 4.0 I can do this setting the alpha property to 0 in the xml layout designer. But when I work with Android 2.2 i can't use that property, Eclipse mark it as an error and tell me that i can't use it. I tried to make it transparent writting this java code: final Spinner cmbCategorias = (Spinner) findViewById(R.id.cmbCategorias); cmbCategorias.getBackground().setAlpha(0); and it works, but the text in the spinner keeps visible. Someone