Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ClassNotFound exception when changing view background
    text
    copied!<p>For my activity, I created a new view and saved it in a public static field. I then set the view with setContentView in the activity. However, whenever I try to change the color of the view from another class, I get a exception as follows: </p> <pre><code>java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.TwinBlade.PicturePassword/com.TwinBlade.PicturePassword.LockActivity}: java.lang.ClassNotFoundException: com.TwinBlade.PicturePassword.LockActivity at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229) at android.app.ActivityThread.access$600(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:4945) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: com.TwinBlade.PicturePassword.LockActivity at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) at android.app.Instrumentation.newActivity(Instrumentation.java:1039) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101) ... 11 more java.lang.ClassNotFoundException: com.TwinBlade.PicturePassword.LockActivity at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) at android.app.Instrumentation.newActivity(Instrumentation.java:1039) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229) at android.app.ActivityThread.access$600(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:4945) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>UPDATE: </p> <p>Here is what i did in my activity</p> <pre><code>public static View mView; public void onCreate(Bundle savedInstanceState) { mView = new LinearLayout(this); mView.setBackgroundColor(Color.argb(0, 0, 0, 0)); setContentView(mView); } </code></pre> <p>And to change the color of the view from another class:</p> <pre><code>LockActivity.mView.setBackgroundColor(Color.argb(255, 0, 0, 0)); </code></pre> <p>The activity is added in the manifest and can be launched. </p> <p>Any help would be appreciated</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload