Onclick functionality in android

I am trying to launch new tabactivity on click from one tab activity

I am able to load the things to first activity...... but onclick of Photo button as shown in one of the class in am getting error as shown in the log cat ....

How can i resolve this

Any ideas

AndroidTabRestaurantDescListView.java

public class AndroidTabRestaurantDescListView extends TabActivity {

    // TabSpec Names
        private static final String INBOX_SPEC = "Rating";
        private static final String OUTBOX_SPEC = "Price";
        private static final String PROFILE_SPEC = "Distance";

        Button Photos;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            Photos=(Button) findViewById(R.id.PhotoButton); 

            TabHost tabHost = getTabHost();

            // Inbox Tab
            TabSpec inboxSpec = tabHost.newTabSpec(INBOX_SPEC);
            Intent inboxIntent = new Intent(this, MainActivity.class);
            inboxSpec.setIndicator(INBOX_SPEC);
            // Tab Content
            inboxSpec.setContent(inboxIntent);

            // Outbox Tab
            TabSpec PriceSpec = tabHost.newTabSpec(OUTBOX_SPEC);
            Intent PriceIntent = new Intent(this, PriceDescriptionActivity.class);
            PriceSpec .setIndicator(OUTBOX_SPEC);
            PriceSpec.setContent(PriceIntent);

            // Profile Tab
            TabSpec DistanceSpec = tabHost.newTabSpec(PROFILE_SPEC);
            Intent DistanceIntent = new Intent(this, DistanceDiscriptionActivity.class);
            DistanceSpec .setIndicator(PROFILE_SPEC); 
            DistanceSpec.setContent(DistanceIntent);

            // Adding all TabSpec to TabHost
            tabHost.addTab(inboxSpec); 
            tabHost.addTab(PriceSpec); 
            tabHost.addTab(DistanceSpec); 

            //Set the current value tab to default first tab
            tabHost.setCurrentTab(0);

            //Setting custom height for the tabs
            final int height = 45;
            tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = height;
            tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = height;
            tabHost.getTabWidget().getChildAt(2).getLayoutParams().height = height;




            Photos.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    Intent PhotoIntent=new Intent(AndroidTabRestaurantDescListView.this,AndroidTabRestaurantDescImageListView.class);
                    startActivity(PhotoIntent);

                }
            });

        }

}

manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidbegin.jsonparsetutorial"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity android:name="com.project.findmybuffet.AndroidTabRestaurantDescListView" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.project.findmybuffet.SingleItemView" >
        </activity>


        <activity
            android:name="com.project.findmybuffet.RestaurantDesc"
            android:label="@string/app_name" >
        </activity>

        <activity
            android:name="com.project.findmybuffet.RestaurantPhotos"
            android:label="@string/app_name" >
        </activity>


        <activity
            android:name="com.project.findmybuffet.DistanceDiscriptionActivity">
        </activity>    

        <activity
            android:name="com.project.findmybuffet.PriceDescriptionActivity">
        </activity> 

        <activity
            android:name="com.project.findmybuffet.MainActivity">
        </activity> 

        <activity
            android:name="com.project.findmybuffet.AndroidTabRestaurantDescImageListView">
        </activity> 

        <activity
            android:name="com.project.findmybuffet.DistanceDiscriptionOnlyImageActivity">
        </activity> 

        <activity
            android:name="com.project.findmybuffet.PriceDescriptionOnlyImageActivity">
        </activity> 

    </application>

</manifest>

Log::

09-28 12:12:40.415: I/MemoryCache(1222): MemoryCache will use up to 8.0MB
09-28 12:12:40.875: D/dalvikvm(1222): GC_EXTERNAL_ALLOC freed 313K, 50% free 2967K/5895K, external 2130K/2137K, paused 119ms
09-28 12:12:40.925: I/MemoryCache(1222): cache size=47000 length=1
09-28 12:12:41.105: I/MemoryCache(1222): cache size=111500 length=2
09-28 12:12:41.245: I/MemoryCache(1222): cache size=179940 length=3
09-28 12:12:41.285: I/MemoryCache(1222): cache size=237060 length=4
09-28 12:12:48.255: D/AndroidRuntime(1222): Shutting down VM
09-28 12:12:48.255: W/dalvikvm(1222): threadid=1: thread exiting with uncaught exception (group=0x40015560)
09-28 12:12:48.287: E/AndroidRuntime(1222): FATAL EXCEPTION: main
09-28 12:12:48.287: E/AndroidRuntime(1222): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidbegin.jsonparsetutorial/com.project.findmybuffet.AndroidTabRestaurantDescImageListView}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidbegin.jsonparsetutorial/com.project.findmybuffet.RatingDescriptionOnlyImageActivity}; have you declared this activity in your AndroidManifest.xml?
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.os.Looper.loop(Looper.java:123)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.app.ActivityThread.main(ActivityThread.java:3683)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at java.lang.reflect.Method.invokeNative(Native Method)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at java.lang.reflect.Method.invoke(Method.java:507)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at dalvik.system.NativeStart.main(Native Method)
09-28 12:12:48.287: E/AndroidRuntime(1222): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidbegin.jsonparsetutorial/com.project.findmybuffet.RatingDescriptionOnlyImageActivity}; have you declared this activity in your AndroidManifest.xml?
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.app.ActivityThread.resolveActivityInfo(ActivityThread.java:1457)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:277)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.widget.TabHost.setCurrentTab(TabHost.java:326)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.widget.TabHost.addTab(TabHost.java:216)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at com.project.findmybuffet.AndroidTabRestaurantDescImageListView.onCreate(AndroidTabRestaurantDescImageListView.java:44)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-28 12:12:48.287: E/AndroidRuntime(1222):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
09-28 12:12:48.287: E/AndroidRuntime(1222):     ... 11 more
Jon Skeet
people
quotationmark

The error message is very descriptive:

Unable to find explicit activity class {com.androidbegin.jsonparsetutorial/com.project.findmybuffet.RatingDescriptionOnlyImageActivity}; have you declared this activity in your AndroidManifest.xml?

And the answer is: no, you haven't declared that activity in your manifest. You've got plenty of other activities in your manifest, but not that one.

As well as simply fixing this by adding the activity to your manifest, I suggest you take a step back and think about how you could have figured this out for yourself. Did you read the log file carefully? Did you somehow miss the error message I quoted? (Always look for "cause" exception messages.) It's really important to learn how to diagnose things for yourself - so see if you can work out why you didn't quite get there this time, so that you can improve for next time.

people

See more on this question at Stackoverflow