笔记10--遇到的错误

1、activity未注册

protected void onCreate(Bundle savedInstanceState) {
// TODO 自动生成的方法存根
super.onCreate(savedInstanceState);

但是若改成系统生成的,就正常了。原因是未在AndroidMainfest.xml文件注册Activity。

正好说下怎么新建Activity:

1)新建一个类,继承自android.app.Activity类。2)创建一个xml文件3)打开AndroidMainfest.xml,注册Activity。直接写源码吧:

<activity android:name="cn.test.mallApp.activity.OrderDetailsActivity" android:launchMode="singleTask"></activity>

2、Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.

Failed to find style 'textViewStyle' in current theme

网上给出的一种解决方法:XML图形界面  右上角Theme选择 Theme或者Theme.Black

当然,如果你的工程原来没这个问题,就直接clean下就好了。
3、Activity not started, its current task has been brought to the front:这种情况只需重启adb。
4、ScrollView遇到的一个问题:ScrollView can host only one direct child。

解决方法:主要是ScrollView内部只能有一个子元素,所以需要把所有的子元素放到一个LinearLayout或RelativeLayout等其他布局方式中。

5、the parent child already has a parent .You must call removeVie() on the child's parent first:
原因是要添加的控件本来就有一个父类了,现在又要给他增加一个父类,java不支持多继承的,所以肯定报错。解决方法:1)要么动态写一个控件。2)要么添加控件的父类,而不是控件本身。
6、端口被占用:“Please ensure that adb is correctly located at 'E:/src/android23sdk/android-sdk_r08-windows/android-sdk-windows/platform-tools' and can be executed.”    
这种情况是端口被占用。思路:先找到adb用哪个端口,然后找到该端口被哪个进程占用,最后结束该进程。

1)要想知道adb用哪个端口,必须先将adb.exe路径(一般都sdk\platform-tools\)加入path中,否则无法在cmd中操作它。

OK,加入path后,在cmd中输入adb nodaemon server 。就知道adb用哪个端口了。

2)继续输入netstat -ano | findstr "5037"   ,找到占用该端口的pid值。继续输入:tasklist|findstr "6540",可知哪个进程占用了该端口。

3)任务管理器中结束该进程。

7、错误信息:FATAL EXCEPTION MAIN:java.lang.ClassCastException:android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams.可能原因:1)布局参数错误2)跟错误5相同原因。

8、空指针异常:1)定义对象,未实例化。举例:List<List<Bitmap>> childGoodsIcon=null;然后直接给他赋值了。应该先List<List<Bitmap>> childGoodsIcon=new ArrayList<List<Bitmap>> childGoodsIcon;

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值