please trace my code i m getting error like
<pre><code>package com.sampleapp;

import java.util.ArrayList;


import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Paint.Align;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

@SuppressWarnings("unused")
public class ContextThemeWrapper extends ContextWrapper 
{
    private Context mBase;

         private int mThemeResource;
         private Resources.Theme mTheme;
         private LayoutInflater mInflater;

         public  ContextThemeWrapper() {

             super(null);

         }


         public  ContextThemeWrapper(Context base, int themeres) {
             super(base);

             mBase = base;
             mThemeResource = themeres;
         }
         @Override protected void attachBaseContext(Context newBase) {
             super.attachBaseContext(newBase);
             mBase = newBase;

         }

         @Override public void setTheme(int resid) {
             mThemeResource = resid;
             initializeTheme();
         }
         @Override public Resources.Theme  getTheme() {
             if (mTheme != null) {
                 return mTheme;
             }
             if (mThemeResource == 0) {
                 mThemeResource = com.sampleapp.R.style.GreenText;
             }
             initializeTheme();
             return mTheme;
         }
         @Override 
         public Object getSystemService(String name) {
             if (LAYOUT_INFLATER_SERVICE.equals(name)) {

                 if (mInflater == null) {

                     mInflater = LayoutInflater.from(mBase).cloneInContext(this);

                 }

                 return mInflater;
             }
             return mBase.getSystemService(name);
         }

         protected void  onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
             theme.applyStyle(resid, true);

         }

         private void initializeTheme() {
             final boolean first = mTheme == null;
             if (first) {
                 mTheme = getResources().newTheme();
                 Resources.Theme theme = mBase.getTheme();

                 if (theme != null) {
                     mTheme.setTo(theme);
                 }
             }
            onApplyThemeResource(mTheme, mThemeResource, first);
        }

    }
</code></pre>

<p>and in LogCat i m getting error like below....</p>

<pre><code>03-05 12:27:57.405: ERROR/AndroidRuntime(364): Uncaught handler: thread main exiting due to uncaught exception
03-05 12:27:57.425: ERROR/AndroidRuntime(364): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sampleapp/com.sampleapp.ContextThemeWrapper}: java.lang.ClassCastException: com.sampleapp.ContextThemeWrapper
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at android.os.Looper.loop(Looper.java:123)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at android.app.ActivityThread.main(ActivityThread.java:4363)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at java.lang.reflect.Method.invokeNative(Native Method)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at java.lang.reflect.Method.invoke(Method.java:521)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at dalvik.system.NativeStart.main(Native Method)
03-05 12:27:57.425: ERROR/AndroidRuntime(364): Caused by: java.lang.ClassCastException: com.sampleapp.ContextThemeWrapper
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
03-05 12:27:57.425: ERROR/AndroidRuntime(364):     ... 11 more
</code></pre>
