Category : android-spinner

I want to make a spinner using retrofit 2, I successfully fetch my data and show it in spinner but when I try to show the selected option in textview it shows me blank here is my onResponse: @Override public void onResponse(Call<ListModel> call, Response<ListModel> response) { ListModel data = response.body(); if (data.getStatuscode().equals("100")) { category.clear(); for ..

Read more

I have created a custom spinner style and am initializing the Spinner with that style // Spinner selectField = new Spinner(context); // regular spiner initialization Spinner selectField = new Spinner(new ContextThemeWrapper(context, R.style.SpinnerStyle)); adapter = new ArrayAdapter<SpinnerItem<U>>(context, R.layout.spinner_layout, new ArrayList<SpinnerItem<U>>()); adapter.setDropDownViewResource(R.layout.spinner_item_layout); The style: <style name="SpinnerStyle" parent="@style/Widget.AppCompat.Spinner"> <item name="android:spinnerMode">dropdown</item> <item name="overlapAnchor">true</item> <item name="android:divider">@color/separator_color</item> <item name="android:dividerHeight">1dp</item> <item name="android:background">@drawable/spinner_background</item> ..

Read more

I am trying to create an adapter that utilizes data from spinners as well as text views. @Override public RecipeViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { View mView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_list,viewGroup,false); return new RecipeViewHolder(mView); } @Override public void onBindViewHolder(@NonNull RecipeViewHolder recipeViewHolder, int i) { recipeViewHolder.imageView.setImageResource(myrecipeList.get(i).getImage()); recipeViewHolder.mTitle.setText(myrecipeList.get(i).getName()); recipeViewHolder.mMeal.setSelection(getIndex(recipeViewHolder.mMeal, myrecipeList.get(i).getMeal())); recipeViewHolder.mDifficulty.setSelection(getIndex2(recipeViewHolder.mDifficulty, myrecipeList.get(i).getDifficulty())); } @Override public int getItemCount() { ..

Read more

I have zero code inside my MainActivity, only the XML layout I created and the Spinner is leaking, not sure why this is happening or how I can fix this. Does anyone know why? I’m using the LeakCanary Library public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } ..

Read more

I have one problem with spinner and the recyclerView when selecting the number from Spinner array it’s not retrieve from the firebase database. and if I put a number manually in a query in orderBy it works and retrieves the data from firebase. query = firestore.collection("ahmed").orderBy( "04", Query.Direction.DESCENDING); Needs : When selecting from the spinner ..

Read more

I am trying to discriminate the selected item of a Spinner by its (multilanguage) text. Here is my default strings.xml content: <string-array name="spinner_items"> <item>length</item> <item>weight</item> <item>temperature</item> </string-array> And this is another strings.xml (Italian language) content: <string-array name="spinner_items"> <item>lunghezza</item> <item>peso</item> <item>temperatura</item> </string-array> I set up my Spinner items in this way: val items = resources.getStringArray(R.array.spinner_items) spinner.adapter ..

Read more