dimanche 17 mai 2015

Data FROM fragment TO activity

I'm trying to pass data from a fragment to an activity using a method in the Activity:

public void setID(int i,int j)
    {
        theme = i;
        thread = j;
    }

and then, from the fragment I use the Intent to create the activity and pass the data with:

private class ListItemClickListener implements ListView.OnItemClickListener {
        @Override
        public void onItemClick(AdapterView arg0, View arg1, int position, long arg3)
        {
            int pos=position+1;
            ThreadActivity threadactivity = new ThreadActivity();
            threadactivity.setID(id,pos);
            Intent q = new Intent(getActivity(), threadactivity.getClass());
            startActivity(q);
        }
    }

but, when the activity starts the values of "i" and "j" are 0. What I'm doing wrong?

Aucun commentaire:

Enregistrer un commentaire