1
私のアプリケーションにはタブがあり、タブにはフラグメントが含まれています。フラグメントにはカードビューがあります。私はcardviewをクリックすると、私はthisのように動作するWebviewにしたいが、私はエラーが発生しています。 マイwebview.xmlアダプタでWebviewを使用する
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/mywebview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
マイデータアダプタ
public static class ContentViewHolder extends RecyclerView.ViewHolder {
protected TextView title;
protected TextView description;
protected TextView date;
protected ImageView imgSrc;
protected String urlS;
protected int itemPos;
WebView mWebView;
AdvancedWebView vw;
public ContentViewHolder(View v) {
super(v);
title = (TextView) v.findViewById(R.id.title);
description = (TextView) v.findViewById(R.id.descript);
date = (TextView) v.findViewById(R.id.date);
imgSrc=(ImageView)v.findViewById(R.id.thumbnail);
v.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
/*Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlS));
v.getContext().startActivity(myIntent);*/
//there is a problem
mWebView =(WebView)v.findViewById(R.id.mywebview);
mWebView.loadUrl("http://www.google.com");
}
});
}
}
私はそれを修正することができますどのようにエラー
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.oguz.topluluk, PID: 3449
java.lang.NullPointerException
at com.example.oguz.topluluk.WebDataAdapter$ContentViewHolder$1.onClick(WebDataAdapter.java:113)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
?私はアンドロイドが初めてです。私を導くことができますか?