解决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!
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 :
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 :
Now you have it set, your ready to start putting data in, and pulling data out, use the following
相关文章推荐
- 举例说明关于android编程中遇到的java.lang.ClassCastException: android.app.Application问题的原因及解决办法
- 解决问题:java.lang.ClassCastException: android.app.Application
- 解决问题java.lang.ClassCastException: android.app.Application
- Android 用webService产生java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive错误的解决
- java.lang.ClassCastException: android.app.Application cannot be cast to *****
- android java.lang.ClassCastException android.app.Application
- java.lang.ClassCastException: android.app.Application cannot be cast
- Android 用axis2 webService产生java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive错误的解决方法
- android java.lang.ClassCastException android.app.Application解决方案
- java.lang.ClassCastException: android.app.Application cannot be cast to错误
- java.lang.ClassCastException: android.app.Application cannot be cast to
- 解决异常:java.lang.ClassCastException:android.app.Aplication cannot be cast to 类名
- java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.MyApplication
- Android 用webService产生java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive错误的解决 .
- java.lang.ClassCastException: android.app.Application cannot be cast to serialport_api.sample.App问题
- java.lang.ClassCastException: android.app.Application cannot be cast to
- java.lang.ClassCastException: android.app.Application cannot be cast to serialport_api.sample.App问题
- java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.MyApplication
- java.lang.ClassCastException: android.app.Application
- Android 用webService产生java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive错误的解决 .