2014-01-18 54 views
0

我想學習編程。我目前正在使用eclipse。我已經下載了我需要的每一個sdk,但是仍然當我打開模擬器時,我已經制作了一個按鈕:不幸的是,倒計時器已經停止。我試圖重新啓動模擬器。這是我的代碼:AVD按鈕失敗

import android.os.Bundle; 
import android.app.Activity; 
import android.content.Intent; 
import android.view.Menu; 
import android.view.View; 
import android.widget.Button; 

public class MainActivity extends Activity implements View.OnClickListener { 

Button button1, button2, button3; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    button1 = (Button) findViewById(R.id.btn5); 
    button2 = (Button) findViewById(R.id.btn60); 
    button3 = (Button) findViewById(R.id.btn90); 

    button1.setOnClickListener(this); 
    button2.setOnClickListener(this); 
    button3.setOnClickListener(this); 
} 

@Override 
public void onClick(View v) { 
    switch (v.getId()) { 
    case R.id.btn5: 
     Intent intent = new Intent(MainActivity.this, _5.class); 
     startActivity(intent); 
     break; 
    case R.id.btn60: 
     Intent intent1 = new Intent(MainActivity.this, _60.class); 
     startActivity(intent1); 
     break; 
    case R.id.btn90: 
     Intent intent2 = new Intent(MainActivity.this, _90.class); 
     startActivity(intent2); 
     break; 
    } 
} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.main, menu); 
    return true; 
} 

} 

我試圖使xClick文件中的onClick,但同樣的發生,所以我嘗試了其他方式。有人知道這個問題?

+0

這不是AVD的問題;當它說「不幸...已停止」時,意味着代碼中發生了運行時錯誤。檢查詳細描述錯誤的logcat輸出並在此處發佈(以紅色查找文本)。如果你不知道如何找到它,在Eclipse中使用Window-> ShowView-> LogCat。 – NigelK

回答

0
`Unfortunately countdowner has stopped.` 

表示您的應用程序出現運行時錯誤。打開Logcat並在這裏發佈它顯示的錯誤是什麼。您可以通過選擇基於錯誤,發佈您的代碼和下面的logcat中在Eclipse

Window --> Show View --> LogCat 

做到這一點,我們應該能夠幫助你

+0

我發佈了代碼作爲answear。這是需要評論的時間 – user3191719

0

android.content.ActivityNotFoundException:無法找到顯式活動類{com.epstudios.Countdowner/com.epstudios.Countdowner._60};你有沒有在你的AndroidManifest.xml中聲明這個活動?

您需要聲明清單中應該可以與Intent聯繫的所有活動。

+0

我發現這個問題忘了在Android Manifest中加入: user3191719

0
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.epstudios.Countdowner/com.epstudios.Countdowner._60}; 

你是否在你的AndroidManifest.xml中聲明瞭這個活動? android.content.ActivityNotFoundException: Unable to find explicit activity class {com.epstudios.Countdowner/com.epstudios.Countdowner._60} - >這清楚地表明您尚未在Manifest文件中聲明您的活動。

執行以下操作:

  1. 聲明活動清單文件按照上面的錯誤消息
  2. 待辦事項項目 - >清潔和運行
  3. 如果仍然發現錯誤,...將您的manifest.xml與logcat錯誤一起發佈