java.lang.RuntimeException异常,请大神赐教!!!
Process: com.example.admin.emotion, PID: 19604
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.admin.emotion/com.example.admin.emotion.MainFragment}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2793)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6524)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.example.admin.emotion.MainFragment.initView(MainFragment.java:80)
at com.example.admin.emotion.MainFragment.onCreate(MainFragment.java:59)
at android.app.Activity.performCreate(Activity.java:6910)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6524)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
出问题的代码:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.content_main);
fragmentManager = getSupportFragmentManager();
initView();
setChioceItem(0);
}
private void initView() {
firstImage = (ImageView) findViewById(R.id.first_image);
secondImage = (ImageView) findViewById(R.id.second_image);
thirdImage = (ImageView) findViewById(R.id.third_image);
fourthImage = (ImageView) findViewById(R.id.fourth_image);
firstText = (TextView) findViewById(R.id.first_text);
secondText = (TextView) findViewById(R.id.second_text);
thirdText = (TextView) findViewById(R.id.third_text);
fourthText = (TextView) findViewById(R.id.fourth_text);
firstLayout = (RelativeLayout) findViewById(R.id.first_layout);
secondLayout = (RelativeLayout) findViewById(R.id.second_layout);
thirdLayout = (RelativeLayout) findViewById(R.id.third_layout);
fourthLayout = (RelativeLayout) findViewById(R.id.fourth_layout);
firstLayout.setOnClickListener(MainFragment.this);
secondLayout.setOnClickListener(MainFragment.this);
thirdLayout.setOnClickListener(MainFragment.this);
fourthLayout.setOnClickListener(MainFragment.this);
}
相关推荐
Java异常处理运行时异常(RuntimeException)详解及实例
Java异常处理运行时异常(RuntimeException)详解及实例Java异常处理是Java编程中一个非常重要的概念,RuntimeException是Java异常处理中的一种特殊类型的异常。
解决 java.lang.RuntimeException: Could not generate DH keypair异常处理所需的bcprov的jar
解决 java.lang.RuntimeException: Could not generate DH keypair异常处理。bcprov-ext-jdk15on-1.60、bcprov-jdk1
java.lang.RuntimeException: Unsupported algorithm: HmacSHA1解决方法
java.lang.RuntimeException: Unsupported algorithm: HmacSHA1 解决方法,阿里云
java.lang.runtimeexception unexpected subelement
总的来说,"java.lang.runtimeexception unexpected subelement" 是一种典型的编程异常,它提示你在处理结构化数据时遇到了意料之外的情况。
javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair 解决方法总结
然而,当你遇到“javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair”的错误时,这意味着在建立


