Get Recycler View Items In Spinner In Another Activity
I use retrofit2 to get a category list with a model class and recyclerview adapter to get category items. In another activity I have a spinner to show category items. How can I get
Solution 1:
You were doing fine, now in the other activity, on your onCreate() method, do this:
Intent intent = getIntent();
catId = intent.getStringExtra("catid");
catTitle = intent.getStringExtra("cattitle");
String[] x = newString[]{catId,catTitle};
ArrayAdapter<String> adapterX = newArrayAdapter<>(this, android.R.layout.your_spinner_in_xml, x);
spinner.setAdapter(adapterX);
Solution 2:
If i get question you want access to List in two activity. If so then you have several way
1 : Store To local Database or SharedPreferences
2 : use static
variables(easy way)
When you get list of category from retrofit response, store it to static List like below
publicstaticList<Category> cats;
Then in OnResponse()
cats = response.body().getCats();
Now you access cats in anOther activtiy.
Post a Comment for "Get Recycler View Items In Spinner In Another Activity"