开发者

Android basic activity call 2 pages with 1 button respectivly found no erros on validate still won't work in AVD

Can someone tell me whats wrong?? lost

Thanks,Mike

P.S.

I figured this might work instead of the splash for 1st page.

page1 or activity 1

package com.test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class test1 extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button next = (Button) findViewById(R.id.Button01);
        next.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
        Intent myIntent = new Intent(view.getContext(),test2.class);
        startActivityForResult(myIntent, 0);

    }
        });
    }
    }

page2 or activity 2

package com.test;
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;

    public class test2 extends Activity {开发者_Python百科

    /** Called when the activity is first created. */
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main2);

        Button next = (Button) findViewById(R.id.Button02);
        next.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
        Intent intent = new Intent();
        setResult(RESULT_OK, intent);
        finish();
                   }
               }) ;
        }


}

Manifiest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.test"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".test1"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Activity2"></activity>

    </application>
</manifest>


What is really wrong is you posting a question on StackOverflow, asking "Can someone tell me whats wrong??", without even taking the time to describe what symptoms you are experiencing. You are lucky that I am in a pretty good mood right now.

There are at least two problems:

  1. Your manifest refers to an Activity2 that does not appear to exist

  2. Your activity test2 is not defined in the manifest


I am guessing you just created your manifest incorrectly, seems that you have test2 as the class but tell the manifest it's name is Activity2.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜