android开发-java.lang.NullPointerException 在学习armenu时候遇到这问题的

问题描述

java.lang.NullPointerException 在学习armenu时候遇到这问题的
java.lang.NullPointerException
at com.administrator_example.icm_arcmenu.view.ArcMenu.layoutButton(ArcMenu.java:137) 这句:mCButton.setOnClickListener(this);
at com.administrator_example.icm_arcmenu.view.ArcMenu.onLayout(ArcMenu.java:129)
at android.view.View.layout(View.java:14841)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
at android.view.View.layout(View.java:14841)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14841)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:502)
at android.view.View.layout(View.java:14841)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14841)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1717)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1571)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1480)
at android.view.View.layout(View.java:14841)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14841)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1986)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1743)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5603)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
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:5146)
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:732)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
at dalvik.system.NativeStart.main(Native Method)

                    private void layoutButton() {    mCButton = getChildAt(0);    mCButton.setOnClickListener(this);    int l = 0;//子布局左边界与父布局左边界的距离    int t = 0;//子布局上边界与上边界的距离  r:子布局右边界与父布局左边界的距离 b:子布下边界与父布局上边界    int width = mCButton.getMeasuredWidth(); //子布局宽度    int height = mCButton.getMeasuredHeight();    switch (mpostion) {        case LEFT_TOP:            l = 0;            t = 0;            break;        case LEFT_BOTTOM:            l=0;            t=getMeasuredHeight()-height;            break;        case RIGHT_TOP:            l = getMeasuredWidth()-width;            t = 0;            break;        case RIGHT_BOTTOM:            l = getMeasuredWidth()-width;            t = getMeasuredHeight()-height;            break;    }    mCButton.layout(ltl+widtht+height);

解决方案

你这个是子布局?将this换成XXX.class试试。

解决方案二:
看看是哪个对象为null了,所以报错

时间: 2024-11-02 23:38:07

android开发-java.lang.NullPointerException 在学习armenu时候遇到这问题的的相关文章

ssh-学习用MyEclipse 2013开发SSH项目遇到java.lang.NullPointerException问题,请帮助!

问题描述 学习用MyEclipse 2013开发SSH项目遇到java.lang.NullPointerException问题,请帮助! SaveOfficeAction.java出错:java.lang.NullPointerException package we.app.action; import we.app.data.*; import com.opensymphony.xwork2.ActionSupport; public class SaveOfficeAction exten

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayShowHomeEnabled(boolean)' on

/********************************************************************************* * Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayShowHomeEnabled(boolean)' on a null object referenc

ndroid-新人求助 java.lang.NullPointerException

问题描述 新人求助 java.lang.NullPointerException 04-26 21:42:40.039: E/AndroidRuntime(1125): FATAL EXCEPTION: main 04-26 21:42:40.039: E/AndroidRuntime(1125): Process: com.example.remotecontrol, PID: 1125 04-26 21:42:40.039: E/AndroidRuntime(1125): java.lang

sharepreferences-安卓:java.lang.NullPointerException:

问题描述 安卓:java.lang.NullPointerException: logcat显示错误: FATAL EXCEPTION: main Process: org.droidplanner, PID: 21924 java.lang.RuntimeException: Unable to resume activity {org.droidplanner/org.droidplanner.android.activities.FlightActivity}: java.lang.Nul

android-在fragment转换中出现java.lang.NullPointerException

问题描述 在fragment转换中出现java.lang.NullPointerException 最近学校让做个android音乐播放器,我跟着论坛的教学做到这里时会出现闪退的问题,不知道怎么解决,求助(我是小白,如果可以请说详细些,谢谢啦) 解决方案 http://bbs.csdn.net/topics/390509766 解决方案二: 这是出错的代码 package com.example.test_01; import android.app.Fragment;import androi

java.lang.NullPointerException

问题描述 学习做JSP网页,在前一个网页中做一个查询表单,这个网页中处理查询,可是处理到Stringsale_low_price=request.getParameter("sale_low_price"); 出现java.lang.NullPointerException错误,百度了一下,说是调用了空对象,于是改为Stringsale_low_price=request.getParameter("sale_low_price");if(sale_low_pric

Android开发笔记之Intent初级学习教程_Android

本文讲述了Android开发笔记之Intent初级学习教程.分享给大家供大家参考,具体如下: 项目创建步骤: New Android Project-> Project name:Intent Build Target:Android 2.2 Application name:IntentDemo Package name:com.b510.intent.activity Create Activity:MainActivity Min SDK Version:8 Finish 1.拨打电话 按

Android异常 java.lang.IllegalStateException解决方法_Android

Android异常详情介绍 这种异常我遇到以下两种情况: 1. java.lang.IllegalStateException: No wrapped connection. 2.java.lang.IllegalStateException: Adapter is detached. 原因: 1.单线程一次执行一个请求可以正常执行,如果使用多线程,同时执行多个请求时就会出现连接超时. 2.HttpConnection没有连接池的概念,多少次请求就会建立多少个IO,在访问量巨大的情况下服务器的I

Android开发笔记之Intent初级学习教程

本文讲述了Android开发笔记之Intent初级学习教程.分享给大家供大家参考,具体如下: 项目创建步骤: New Android Project-> Project name:Intent Build Target:Android 2.2 Application name:IntentDemo Package name:com.b510.intent.activity Create Activity:MainActivity Min SDK Version:8 Finish 1.拨打电话 按