消息关闭
    暂无新消息!
网上的那些错误解决办法都不适合我的代码 我吧代码截图放下面,用Android studio写的
错误日志:06-06 11:36:17.445 2638-2638/com.example.xm503xk E/AndroidRuntime: FATAL EXCEPTION: main
                                                                   Process: com.example.xm503xk, PID: 2638
                                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.xm503xk/com.example.xm503xk.activity.ArticleDetailActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.webkit.WebView.loadUrl(java.lang.String)' on a null object reference
                                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                       at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                       at android.os.Looper.loop(Looper.java:154)
                                                                       at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.webkit.WebView.loadUrl(java.lang.String)' on a null object reference
                                                                       at com.example.xm503xk.activity.ArticleDetailActivity.onCreate(ArticleDetailActivity.java:116)
                                                                       at android.app.Activity.performCreate(Activity.java:6679)
                                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
                                                                       at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
                                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                       at android.os.Looper.loop(Looper.java:154) 
                                                                       at android.app.ActivityThread.main(ActivityThread.java:6119) 
                                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

代码如下:public class ArticleDetailActivity extends AppCompatActivity {
    /*int resid;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_article_detail);
        Intent intent=getIntent();
        resid =intent.getIntExtra("resid",1);
        String str= String.valueOf(resid);
        Log.i("mymessage",str);
        Toast.makeText(this,str,Toast.LENGTH_SHORT).show();

    }*/
    private int resid;
    private int userid;
    private Context context;
    private WebView webView;
    private Boolean flagcollect = false;//收藏标志
    private Boolean flagfocus = false;//关注标志
    private CollectModel collectmodel;//收藏model
    private SharedPreferences sp;//简单存储
    private String sessionID = "";  //sessionid
    final static String PREF_NAME = "loginPref";
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu, menu);//加载菜单布局
        collectmodel = new CollectModel();//实例化对象
        collectmodel.exist("article", resid, sessionID, listener);//判断是否收藏
        return true;
    }
    CollectListener listener = new CollectListener() {
        @Override
        public void onResponse(String msg) {
            //获取菜单视图
            ActionMenuItemView item = (ActionMenuItemView) findViewById(R.id.menucollect);
            //根据mode中response返回的字符串区分返回结果
            switch (msg) {
                case "2":
                    System.out.println("----收藏成功");
                    flagcollect = true;
                    item.setTitle("取消收藏");
                    break;
                case "1":
                    System.out.println("----收藏失败");
                    break;
                case "5":
                    System.out.println("----取消收藏成功");
                    flagcollect = false;
                    item.setTitle("收藏");
                    break;
                case "4":
                    System.out.println("----取消收藏失败");
                    break;
                case "7":
                    System.out.println("----已收藏");
                    flagcollect = true;
                    item.setTitle("取消收藏");
                    break;
                case "8":
                    System.out.println("----未收藏");
                    flagcollect = false;
                    item.setTitle("收藏");
                    break;
                default:
                    Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = ArticleDetailActivity.this;
        setContentView(R.layout.activity_article_detail);
        Intent intent = get