How to send data from one Fragment to another Fragment?


Hi I know there are answers of this question. I have tried all of them but it is not working in my app. I am developing an app that has 3 Fragment activity. First fragment shows a website, second fragment has listview and third Fragment has another listview. Now I want to send URL from third fragment to first fragment when user clicks on listitem..This is what I have done.

I am sending string url from this Fragment to first fragment.

list.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> adapter, View view, int position,
            long id) {
        FragmentC fragment  new  FragmentC();
        final Bundle bundle  new Bundle();
        bundle.putString("position", "");            fragment.setArguments(bundle);}

This is first fragment where I need the url and Want to show in the webview.

String url"";
        Bundle args  getArguments();
        if (args  ! null){
        url  args.getString("position");
        WebView webView (WebView) V.findViewById(;
        WebSettings webViewSettings  webView.getSettings();

When I click on list item I don’t see anything . It does not redirect me to the first fragment.Please help me..


Use Bundle to send String:

//Put the value
YourNewFragment ldf  new YourNewFragment ();
Bundle args  new Bundle();
args.putString("YourKey", "YourValue");

//Inflate the fragment
getFragmentManager().beginTransaction().add(, ldf).commit();

In onCreateView of the new Fragment:

//Retrieve the value
String value  getArguments().getString("YourKey");

Answered By – João Marcos

Leave a Comment