Skip to content Skip to sidebar Skip to footer

How To Pass Id Of One Json To Next Activity?

hello I am new to android in my app i have one ListFragment activity in which i am getting data perfectly where i have list of users now i want that after click on any user i need

Solution 1:

Try to override onListItemClick in fragment :

@Override
publicvoidonListItemClick(ListView l, View v, int position, long id) {
    Intent intent = new Intent(getActivity(), ProfilePage.class);
    intent.putExtra("match_detail_id", aList.get(position).get(TAG_MATCH_ID));
    startActivity(intent);
}

Instead of manual setOnItemClickListener to listview so no required this code :

listview=(ListView)rootView.findViewById(android.R.id.list);

listview.setOnItemClickListener(new OnItemClickListener() {   
    @Override
    publicvoidonItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
       Intent intent=new Intent(getActivity().getApplicationContext(),ProfileEdit.class);
       intent.putExtra("position", arg2);
       startActivity(intent);
    }
});

Note : when you use ListFragment no need to find Listview and set item click as well as setAdapter manually,directly get all method ready like setAdapter() and onListItemClick.

Solution 2:

Intent intent = newIntent(getBaseContext(), NewActivity.class);
intent.putExtra("KEY", Value);
startActivity(intent)

Solution 3:

Try with below code:

listview.setOnItemClickListener(new OnItemClickListener() {

            @Override
            publicvoidonItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {
                // TODO Auto-generated method stub
                Intent intent=new Intent(getActivity(),ProfileEdit.class);
                intent.putExtra("match_detail_id", arg2);
                startActivity(intent);
            }
        });

//get this data as below in ProfileEdit class

String matchId=this.getIntent().getStringExtra(""match_detail_id"");
if(matchId.trim().length()>0){
    USER_URL="http://gujjumatch.com/webservice/matchingdetails?version=apps&match_detail_id="+user_match_id;
}else{
    Toast.makeText(ProfileEdit.this,"match id blank",Toast.LENGTH_LONG).show();

}

Post a Comment for "How To Pass Id Of One Json To Next Activity?"