2011-01-20 25 views
0

我是Java Android開發人員的初學者。我正在使用Eclipse SDK 3.6.1版本。我試圖做這件事情:在第一類(佈局 - main.xml)是按鈕「hello」,它調用新類(佈局 - second.xml),在這個類中按鈕「hello2」,它calss新類。當我按下第一個按鈕「hello」時,我無法做到這一點,因爲我收到這條消息「應用程序(xxxx)意外停止,請再試一次」。如何解決這個問題。我認爲問題是在AndroidManifest.xml:如何調用正確運行幾個類(intents)?

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="net.kodinis_raktas" 
     android:versionCode="1" 
     android:versionName="1.0"> 
    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".veiksmas" 
     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=".second" > 
    <intent-filter> 
<category android:name="android.intent.category.DEFAULT" /> 
    </intent-filter>     
     </activity> 
<activity android:name=".lock"></activity> 
    <intent-filter> 
    </intent-filter> 
</application> 
     <uses-permission android:name="android.permission.SEND_SMS"> 
    </uses-permission> 
    <uses-permission android:name="android.permission.RECEIVE_SMS"> 
    </uses-permission> 
    <uses-sdk android:minSdkVersion="3" /> 
</manifest> 

回答

1

使用adb logcat,DDMS,或在Eclipse中DDMS角度來考察logcat的,看看你的錯誤相關的堆棧跟蹤。這會給你更多的信息。

我建議從.second.lock中刪除<intent-filter>元素,因爲您沒有使用它們。如果您的錯誤來自於嘗試啓動.second,您的類別<intent-filter>的存在可能會阻止該活動的啓動。

0

在我與Android,我認爲你需要後activity android:name=".second"

android:label="@string/app_name">

添加此行的經驗有限