خرید بک لینک

Vote count: 0

I Know there are already questions liked this but there are nothing that work in this program. i get this code from one youtube videos tutorial

 public void ListDrawer() {
    final List<Map<String, String>> studentList = new ArrayList<Map<String, String>>();

    try {
        JSONObject jsonResponse = new JSONObject(jsonResult);
        JSONArray jsonMainNode = jsonResponse.optJSONArray("student_info");

        for (int i = 0; i < jsonMainNode.length(); i++) {
            JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
            String name = jsonChildNode.optString("student_name");
            String number = jsonChildNode.optString("student_id");
            String outPut = name + "-" + number;
            studentList.add(createStudent("Students", outPut));
        }
    } catch (JSONException e) {
        Toast.makeText(getApplicationContext(), "Error" + e.toString(),
                Toast.LENGTH_SHORT).show();
    }
 ////////////////////////////////// UPDATE LISTVIEW ITEMS ONCLICK

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            //Do your logic for getting the student variables here
            Intent intent = new Intent(MainPage.this,Profile.class);

            intent.putExtra("student ", String.valueOf(id));

            startActivity(intent);
        }
    });

//////////////////////////////////////UPDATE
    SimpleAdapter simpleAdapter = new SimpleAdapter(this, studentList,
            android.R.layout.simple_list_item_1,
            new String[] { "Students" }, new int[] { android.R.id.text1 });
    listView.setAdapter(simpleAdapter);
    Toast.makeText(getApplication(), "Logged in Successfully", Toast.LENGTH_SHORT).show();

Above is mylistview and my onItemClicked function

i use json to retrieve the list of students from mysql and view it in listview and now im trying to pass data from the selected student in listview to new activity

Image Screenshot

I use bundle before but it only return null, how can i get the name of the student_name that populated from database using json of the clicked item and show it into new activity?

asked 44 secs ago

برچسب: send data to graphite,send data to server,send data to google spreadsheet,send data to fragment,send data to arduino,send data to iframe,send data to arduino over usb,send data to server javascript,send data to modal,send data to google analytics, نویسنده: استخدام کار تاريخ: دوشنبه 8 شهريور 1395 ساعت: 20:08

صفحه بندی