Skip to content Skip to sidebar Skip to footer

How To Programmatically Reference Multiple String-array By Clicking On List Item

I am new to android programming and wanna know this, I have four string-array defined in string.xml file M

Solution 1:

Since we are talking about data which has a relation, you probably want to use a relational data structure like a relational database. In Android, you can use SQLite.

If you do not expect your data to grow (it will always be the same persons), you could also JSON encode the values and pass the whole string to the next Activity

<resources>
<string-array name="person">
    <item>{"name": "Max", "phone":"123", "address":"XYZ", "areaCode": "1"}</item>
</string-array>
</resources>

Solution 2:

First of all you should really use a database to store such data.

Resources res = getResources();
String[] planets = res.getStringArray(R.array.planets_array);

Then get the element number the user clicked on and access this position in planets.

See this tutorial.

Solution 3:

You can follow some simple steps :

1) Take position of "person_name" when it's click.

2) Pass that position to second activity using intent.

3) Get Values of other string arrays from that position.

Post a Comment for "How To Programmatically Reference Multiple String-array By Clicking On List Item"