我从Main.java出发OnClickListener事件进入About.java中,出现一下问题,请高手帮忙:
Main.javapublic void onClick(View arg0) {
// TODO Auto-generated method stub
System.out.println(arg0.getId());
switch(arg0.getId()){
case R.id.newGame:
break;
case R.id.continueGame:
break;
case R.id.aboutGame:
//要想在android中启动某个activity,需要添加一个Intent类实例
Intent i = new Intent(this,About.class);
startActivity(i);
break;
case R.id.helpGame:
break;
}
}
AndroidManifest.xml<activity android:name="com.yao.rice.About" android:label="@string/aboutTitle"/>显示效果是屏幕闪一下,回到Main页面,标题变了,但是内容没有变
AndroidManifest.xml<activity android:name=".About" android:label="@string/aboutTitle"/>提示错误信息,找不到
我感觉像是很快加载了About然后又回到了Main,或者是我的xml出现问题,但是我检查过我的xml没有错误,请问这是怎么回事

解决方案 »

  1.   

    Intent i = new Intent(this,About.class);
    改成Intent i = new Intent(Main.this,About.class);
    你的代码发不全没发跟,只能这样试试了
      

  2.   

    AndroidManifest中怎么注册了两个About?
    你这样用到的是下面的那个About。
      

  3.   

    你的AndroidManifest种About注册弄错了哦!别写成<activity android:name="com.yao.rice.About" android:label="@string/aboutTitle"/>这样哦,给你一个实例,你按它的格式改动;<?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.yarin.Android.HelloAndroid"(包名)      android:versionCode="1"
          android:versionName="1.0">
        <application android:icon="@drawable/icon" android:label="@string/app_name">
            <activity android:name=".HelloAndroid(Activity名)"
                      android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
        <uses-sdk android:minSdkVersion="5" />
    </manifest>