I parsed a json object using an API and retrieve its data containing ID,Title, Url, Promotion etc now i am displaying it's Title and Promotion in listview and i want to make that list clickable to redirect on it's same url which i am getting from JSON object every list contains different urls. So how can i do it?
for (int i = 0; i < json.length(); i++) {
try {
JSONObject c = json.getJSONObject(i);
String id = c.getString(ID);
Log.e(id, "Json ID inside of it");
String title = c.getString(TITLE);
Log.e(title, "Json ID inside of it");
String url = c.getString(URL);
Log.e(url, "Json ID inside of it");
String offer = c.getString(OFFER);
String enddate =c.getString(ENDDATE);
HashMap<String, String> map = new HashMap<String, String>();
// Add child node to HashMap key & value
map.put(ID, id);
map.put(TITLE, title);
map.put(URL, url);
map.put(OFFER, offer);
map.put(ENDDATE, enddate);
jsonlist.add(map);
Log.e(ID, "check if id ave xsmething");
Log.e(id, "check if id ave xsmething");
Log.e(TITLE, "check if id ave xsmething");
Log.e(title, "check if id ave xsmething");
}
catch (JSONException e) {
e.printStackTrace();
}
}
My XML file is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>