I have the url value in the MainActivity page and i need to pass this url value from ACtivity to Fragment. But when i click the button i'm getting null exception on the line of String url=getArguments().getString("btn_url");
Activity:
Fragment fragment=new About();
if (fragment != null) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.frame_container, fragment, "TAG_FRAGMENT");
transaction.addToBackStack(null);
transaction.commit();
Bundle bundle=new Bundle();
bundle.putString("btn_url", URL);
About fragobj=new About();
fragobj.setArguments(bundle);
}
Fragment:
String url=getArguments().getString("btn_url");
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…