我是新來的fragment.I加載網址在webview裏面的片段,但它沒有加載。在模擬器網頁可能會臨時下來消息即將.in三星galaxy標籤設備來空白可以有人告訴是什麼問題,如何解決webview是不是加載網址裏面的片段在android
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
public class WebViewFragment1 extends Fragment {
WebView loadWeb;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Tell the framework to try to keep this fragment around
// during a configuration change.
setRetainInstance(true);
// Start up the worker thread.
}
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.gcmweb, container, false);
loadWeb=(WebView)layout.findViewById(R.id.loadWeb);
/*String url = "http://unstructure.org/unstruc/unstruc.php?i="
+ "sample test".replaceAll(" ", "-");*/
String url="http://www.google.com/";
loadWeb.loadUrl(url);
return layout;
}
}
在這裏,我的活動動態地添加
FragmentTransaction ft = fm.beginTransaction();
Fragment fragReplace=new WebViewFragment1();
//fm.beginTransaction();
ft.add(R.id.replace_frag_container,fragReplace);
ft.addToBackStack(null);
ft.commit();
感謝
你找到答案? – powder366 2014-01-08 11:15:31