我有一個WebViewFragment
,並試圖讓web視圖使用時,它給了我一個空指針的WebView總是空
public class BallInfoFragment extends WebViewFragment {
long id;
public BallInfoFragment(long id){
this.id = id;
}
@Override
public void onCreate(Bundle state){
super.onCreate(state);
String ball = new String();
Cursor c = getActivity().getContentResolver().query(Balls.CONTENT_URI,new String[] {Balls.ID,Balls.BALL},Balls.ID+"="+id,null,null);
c.moveToFirst();
ball = c.getString(1);
WebView wv = getWebView(); //getWebView always gives me null
爲什麼是空?
這樣做,但它現在不會顯示任何東西。它告訴我,它無法找到我的資產文件夾中的HTML文件,我聲明像這樣'wv.loadUrl(「file /// android_asset/train.html」);'文件名是正確的 – tyczj