Skip to content Skip to sidebar Skip to footer

Not Able To Pass String Value Through Bundle

This question is something serious for me , i need to someone help me regarding this. Actually i am creating an RSS feed app by combining navigation drawer and view pager tabbed ac

Solution 1:

Try the below one,

ldf = newresult(); 
Bundlebundle=newBundle();
FragmentTransactionfragmentTransaction= 
getActivity().getSupportFragmentManager().beginTransaction();
bundle.putString("key","value");
ldf.setArguments(bundle);
fragmentTransaction.addToBackStack("fragBack");
fragmentTransaction.replace(R.id.content_main_layout_frame, ldf);
fragmentTransaction.commit();

Solution 2:

Remove both the transaction and add the below code instead,

ldf = newresult(); 
Bundlebundle=newBundle();
FragmentTransactionfragmentTransaction= 
getActivity().getSupportFragmentManager().beginTransaction();
bundle.putString("key","value");
ldf.setArguments(bundle);
fragmentTransaction.addToBackStack("fragBack");
fragmentTransaction.add(R.id.content_main_layout_frame, ldf);
fragmentTransaction.commit();

Let me know if that helps!

Solution 3:

Try this

publicclassresultextendsFragment {


publicresult() {


// Required empty public constructor
}


@OverridepublicViewonCreateView(LayoutInflater inflater, ViewGroup container,
                     Bundle savedInstanceState) {
View rootview=inflater.inflate(R.layout.fragment_result,container,false);

TextView textView=(TextView)rootview.findViewById(R.id.distext);


if(savedInstanceState!= null) {

    String value = savedInstanceState.getString("YourKey");

    textView.setText(value);

  //  Toast.makeText(getActivity(), value,//   Toast.LENGTH_LONG).show();

}

return rootview;
}

}

Post a Comment for "Not Able To Pass String Value Through Bundle"