I have an array as shown below
private ArrayList<Blogs> parseJSONResponseCar(JSONArray response) {
if (!response.equals("")) {
try {
StringBuilder data = new StringBuilder();
for (int i = 0; i < response.length(); i++) {
JSONObject currentQuestions = response.getJSONObject(i);
String Blue = currentQuestions.getString("text");
String Yellow=currentQuestions.getString("id");
How can I extract the getString("id") value and put it in a new OnClick Listener method??
public void OnUp (View view) {}
Use a global class variable outside function like this:
string globalVar = "";
private ArrayList<Blogs> parseJSONResponseCar(JSONArray response) {
String Yellow=currentQuestions.getString("id");
globalVar = Yellow;
}
public void OnUp (View view) {
string test = globalVar ;
}
If its a web application you can store in Session.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.