2013-09-26 66 views
0

這是代碼。爲什麼我的簡單應用程序無法運行?

package com.example.appfit; 

import android.app.Activity; 
import android.os.Bundle; 

class Main extends Activity{ 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.select); 

    } 

} 

我不能得到,當我試圖運行這個我不幸停下來,問題。另外這裏是select.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/tvSelect" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dp" 
     android:text="@string/select" 
     android:textSize="18sp" 
     android:layout_gravity="center" 
     /> 

</LinearLayout> 

什麼可能是問題?

下也表現

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.appfit" 
    android:versionCode="1" 
    android:versionName="1.0" > 

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

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.example.appfit.Main" 
      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> 

</manifest> 

我不知道怎麼弄的錯誤?我真的很新鮮。

+3

發表您的logcat – Manishika

+0

嘗試通過連接到設備的日誌: '亞行-e logcat的'對於模擬器或設備的'adb -d logcat' - 它會給你完整的堆棧轉儲。 – elimirks

+0

使用Logcat。也許發佈你的Android清單 –

回答

1

變化

class Main extends Activity{ 

public class Main extends Activity{ 
0

確保您已在清單文件中聲明瞭您的活動。

0

可能的問題可能是您沒有提到清單中的主啓動器。檢查你在清單中給出了什麼路徑。並確保你已經提到了Strings.xml文件中的字符串選擇。

0

您可能需要檢查Android Manifest文件。您的活動需要正確註冊爲「啓動活動」。它應該是這個樣子的清單:

<activity 
    android:name="com.example.appfit.Main" 
    android:label="@string/your_app_name"> 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 
相關問題