从我的启动画面开始我的主活动课程。
主要活动包含一个图像按钮,我通过显式意图调用其他类(第二个屏幕)。
但是现在SpleshScreen时间结束后我强行关闭,但当我删除MainActivity的显式意图代码时。
在Splesh Screen之后。我以完美的方式获得了我的MainActivity。>(但是因为我必须进入SecondScreen我把explict的代码放在Intent中)
我想要像SpleshScreen-> MainActivity-> SecondScreen
这样的流程我的LogCat显示以下错误
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): Uncaught handler: thread main exiting due to uncaught exception
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.MainActivity}: java.lang.ClassCastException: android.widget.ImageButton
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2558)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2574)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at android.app.ActivityThread.access$2400(ActivityThread.java:121)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1925)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at android.os.Handler.dispatchMessage(Handler.java:99)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at android.os.Looper.loop(Looper.java:136)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at android.app.ActivityThread.main(ActivityThread.java:4425)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at java.lang.reflect.Method.invokeNative(Native Method)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at java.lang.reflect.Method.invoke(Method.java:521)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at dalvik.system.NativeStart.main(Native Method)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): Caused by: java.lang.ClassCastException: android.widget.ImageButton
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at com.rvappstudios.fingerslayarrr.MainActivity.onCreate(MainActivity.java:24)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2521)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): ... 11 more
07-13 12:14:59.200: ERROR/ActivityManager(1188): SIGNAL_QUIT: to crashed process 2455
我的MainActivity.java代码的imagebutton来调用我的秒屏
public class MainActivity extends Activity
{
private Button play;
//Called when first activity is created
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
play=(Button)findViewById(R.id.down);
play.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent=new Intent(MainActivity.this,SecondScreen.class);
startActivity(intent);
}
});
}
}
我的清单文件代码
<activity android:name=".SplashScreen"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="MainActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="SecondScreen"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait" >
</activity>
答案 0 :(得分:0)
发布MainActivity的源代码及其layout.xml。或者参考MainActivity中的第24行。存在类型不匹配。
答案 1 :(得分:0)
疯狂猜测。
Caused by: java.lang.ClassCastException: android.widget.ImageButton
但你有
private Button play;
play=(Button)findViewById(R.id.down);
你在xml中有Button或ImageButton吗?