您的位置:首页 > 移动开发 > Android开发

解决android java.lang.ClassCastException android.app.Application

2012-01-24 12:46 471 查看
定义类 DemoApp , 结果 Activity 调用始终报类错郁闷呀!
class DemoApp extends Application{
}
下面的配置注意:

<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:debuggable="true"
android:name=".DemoApp">

android:debuggable="true" 允许调试的意思
Firstly, you should create a new class that will behave as our global object, for example :

The above class declares one String, with accessor methods. Soon we will see how this object will be available throughout the application. You can add anything you want onto this object, in my application I have a List of other domain classes that I wanted
to use elsewhere in my application.

Right, now that you have your global class defined, you need to specify this in your AndroidManifest file, otherwise the application won’t know where to find this class, and you will get a ClassNotFoundException

Locate your application tag, and add this into it :

It must reference your fully qualified global state class

Now you have it set, your ready to start putting data in, and pulling data out, use the following

And thats it! Off you go!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐