I’ve basically got a dialogfragment which shows a range of options.
What i am trying to do is,
pass back to the calling activity, which option was selected. This will then, in the original activity call a method.
ATM I am using,
((Activity) method(); , to call the calling activities method from within the dialog,
but this seems to be very in efficient as android response time slows down when doing this.
In other words, How can i simply, and quickly get information back from the fragment i just created?
In activity,
button.setOnClickListener( new OnClickListener() {
public void onClick(View arg0) {
FragmentManager fm = getFragmentManager();
FragClass frag = new FragClass();
frag.show(fm, "fragment_sub_connections");
}
and then in FragClass,
public FragClass()
{
}
@Override
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment_sub_connections, container);
//some code here
}
Create a Listener Interface and allow your activity to implement it, this can be used as a callback.
Then use it like this: