How to switching to new activity from the listview that contains an array of data from a mysql database

Monday, May 12, 2014


**help me please...How to switching to new activity from the listview that contains an array of data from a mysql database?**


enter code here



static String in_idmenu = "id_menu";
static String in_jenismenu = "jenis_menu";
static String in_image_menu = "image_menu";
JSONArray str_json = null;
public String lo_Koneksi,isi ;

ListView list;
LazyAdapter adapter;
ArrayList<HashMap<String, String>> data_map = new ArrayList<HashMap<String, String>>();

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Koneksi lo_Koneksi = new Koneksi();
isi = lo_Koneksi.isi_koneksi();

String link_url = isi+"menu.php";
JSONParser jParser = new JSONParser();
JSONObject json = jParser.AmbilJson(link_url);

try {
str_json = json.getJSONArray("menu");

for(int i = 0; i < str_json.length(); i++){
JSONObject ar = str_json.getJSONObject(i);

String id_menu = ar.getString("id_menu");
String image_menu = ar.getString("image_menu");
String jenis_menu = ar.getString("jenis_menu");

HashMap<String, String> map = new HashMap<String, String>();

map.put(in_idmenu, id_menu);
map.put(in_image_menu, image_menu);
map.put(in_jenismenu, jenis_menu);

data_map.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}

list=(ListView)findViewById(R.id.list);
adapter=new LazyAdapter(this, data_map);
list.setAdapter(adapter);
}`enter code here`






http://ift.tt/1jkf7Ku