looking for some solutions? You are welcome.

SOLVED: ListView from an array received as string from a RecyclerView

Santosh Humagain:

I have a main activity that has a Recyclerview, It displays a list image and a text as the title.

In the main activity I have three array lists; one for the image, one for its title and the last one "array" for a String array.

I am passing the R.array.id as a string into the next activity On Click of an item in the MainActivity. I send the image, title, and the array.

In the second Activity, where I check for incoming intent, Assign them to strings.

String imageUrl = getIntent().getStringExtra("image_url");
String imageName = getIntent().getStringExtra("image_name");
String array= getIntent().getStringExtra("array_id");

Then I have called setArray(array) and then inside the function, I got stuck.

private void setArray(String array) {
    // Stuck here 
}

I don't know what to do. I have set a ListView in the second layout and found this code on this site.

ListView lv = (ListView) findViewById(R.id.extView);
ArrayAdapter<CharSequence> aa = ArrayAdapter.createFromResource(this, R.array.id, android.R.layout.simple_list_item_1);
lv.setAdapter(aa);

Which works, if I have a set the source to a static array id but how do I set it the string I receive?

Tried getString(array), which did not work. I also need to set an onClick listener to the items.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent