I've a library included into my project, and want to define and element inside my XML file, this element type is from a class resides in this library, when I just declares it with the name it gives me an error through running :
<ClassType
android:id="@+id/my_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
and when just declares it as a View
then cast it through run time I'm getting ClassCastException
:
<View
android:id="@+id/my_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
then in Java,
ClassType my_view = (ClassType) findViewById(R.id.my_view);
UPDATE:
the total log when trying to add the whole namespace:
10-26 14:45:47.753: E/AndroidRuntime(1430): FATAL EXCEPTION: main
10-26 14:45:47.753: E/AndroidRuntime(1430): Process: com.lockscreen, PID: 1430
10-26 14:45:47.753: E/AndroidRuntime(1430): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lockscreen/com.lockscreen.LockScreenAppActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.example.ClassType
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.app.ActivityThread.access$800(ActivityThread.java:135)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.os.Handler.dispatchMessage(Handler.java:102)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.os.Looper.loop(Looper.java:136)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.app.ActivityThread.main(ActivityThread.java:5017)
10-26 14:45:47.753: E/AndroidRuntime(1430): at java.lang.reflect.Method.invokeNative(Native Method)
10-26 14:45:47.753: E/AndroidRuntime(1430): at java.lang.reflect.Method.invoke(Method.java:515)
10-26 14:45:47.753: E/AndroidRuntime(1430): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
10-26 14:45:47.753: E/AndroidRuntime(1430): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
10-26 14:45:47.753: E/AndroidRuntime(1430): at dalvik.system.NativeStart.main(Native Method)
10-26 14:45:47.753: E/AndroidRuntime(1430): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.example.ClassType
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
10-26 14:45:47.753: E/AndroidRuntime(1430): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.app.Activity.setContentView(Activity.java:1929)
10-26 14:45:47.753: E/AndroidRuntime(1430): at com.lockscreen.LockScreenAppActivity.onCreate(LockScreenAppActivity.java:75)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.app.Activity.performCreate(Activity.java:5231)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
10-26 14:45:47.753: E/AndroidRuntime(1430): ... 11 more
10-26 14:45:47.753: E/AndroidRuntime(1430): Caused by: java.lang.reflect.InvocationTargetException
10-26 14:45:47.753: E/AndroidRuntime(1430): at java.lang.reflect.Constructor.constructNative(Native Method)
10-26 14:45:47.753: E/AndroidRuntime(1430): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
10-26 14:45:47.753: E/AndroidRuntime(1430): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
10-26 14:45:47.753: E/AndroidRuntime(1430): ... 22 more
10-26 14:45:47.753: E/AndroidRuntime(1430): Caused by: java.lang.NoClassDefFoundError: com.squareup.timessquare.R$styleable
10-26 14:45:47.753: E/AndroidRuntime(1430): at com.example.ClassType.<init>(ClassType.java:99)
10-26 14:45:47.753: E/AndroidRuntime(1430): ... 25 more