我剛開始在這個應用程序上工作我覺得我已經做好了一切(這不是我的第一個應用程序)但是當我嘗試運行它時它崩潰?它給了我沒有錯誤。Android應用程序在主要活動啓動時發生崩潰
下面是主要活動的代碼,然後是manufest,然後是xml佈局。 `
package com.theory.game;
import java.util.Random;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class GameTheoryActivity extends Activity implements View.OnClickListener{
Button play, settings;
int i;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
play.setOnClickListener(this);
settings.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.bPlay:
Random irand = new Random();
i = irand.nextInt(4);
switch(i){
case 0:
Intent GoMillionair = new Intent(GameTheoryActivity.this, millionair.class);
startActivity(GoMillionair);
return;
case 1:
return;
case 2:
return;
case 3:
return;
}
return;
case R.id.bSettings:
return;
}
}
}
Manufest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.theory.game"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application >
<activity
android:name=".GameTheoryActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".millionair" >
<intent-filter>
<action android:name="com.theory.game.MILLIONAIR" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/backgroundimage"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="390dp"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/bPlay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.38"
android:background="@drawable/play" />
<Button
android:id="@+id/bSettings"
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_weight="0.36"
android:background="@drawable/settings" />
</LinearLayout>
</LinearLayout>
`
而且我還有一個類叫做millionair這僅僅是一個普通的類沒什麼,沒什麼我錯了。請檢查這個怎麼回事,讓我知道爲什麼我的應用程序不會開始說它「已停止工作」..謝謝
它給你一個錯誤。檢查LogCat並在此處發佈堆棧跟蹤。 –