为什么这个运行时发生:无法实例活动ComponentInfo? [英] why this runtime is occured :Unable to instantiate activity ComponentInfo?

查看:153
本文介绍了为什么这个运行时发生:无法实例活动ComponentInfo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图定义一个微调,这种运行时异常被抛出。为什么呢?

when I try to define an spinner, this Run time exception is thrown. Why?

推荐答案

您必须初始化onCreate方法的微调,因此移动

You have to initialize your spinner in the onCreate method, so move

CARS_TYPE = (Spinner)findViewById(...);

里面的setContentView后的onCreate()

inside onCreate() after setContentView

一件事,CARS_TYPE不应该是一个常数,更好,如果你把它叫做carsType而不是

one more thing, CARS_TYPE should not be a constant, better if you call it carsType instead

这篇关于为什么这个运行时发生:无法实例活动ComponentInfo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆