Here is what i understood. You have tow fragments(A, B) in an activity. A is a list fragment. on selecting an item in A, you have to pass a String to B.
First override onListItemClick()
in your Fragment A
FragemtA:
public class FragmentA extends ListFragment{
...
void onListItemClick(ListView l, View v, int position, long id){
datapasser.onDatapass(data)//here pass the String
}
}
In your activity's onDataPass method:
void onDataPass(String data){
FragmentB dataUser = getFragmentB();//Your FragmentB object
dataUser.use(data);
}
Fragment B:
public class FragmentB extends Fragment{
...
void use(String data){
//here use the data
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…