切换fragemnt时传递参数
fragment A 中:
LoadUrlFragment loadUrlFragment = new LoadUrlFragment();
<span style="color:#ff0000;"> Bundle b = new Bundle();
b.putString("url_key",url);
loadUrlFragment.setArguments(b);</span>
getSupportFragmentManager().beginTransaction().replace(R.id.container,loadUrlFragment).commit();
fragment B 中
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_load_url,container,false);
<span style="color:#ff0000;"> Bundle b = getArguments();
String url = b.getString("url_key");</span>
WebView wv = (WebView) root.findViewById(R.id.webView);
wv.loadUrl(url);
return root;
}
切换fragemnt时加动画效果
fragment A 中:
<pre name="code" class="java">loadUrlFragment<span style="font-family: Arial, Helvetica, sans-serif;">.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_right); </span>