在eclipse/android AVD中,我收到消息「不幸,已停止」。模擬器無法運行我的應用程序
我檢查了其他問題,但我假設它是特定於我的應用程序。我不確定錯誤的位置,因爲代碼在代碼中沒有顯示任何問題或錯誤。我想知道,如果這可能是我設置我的模擬器的方式,或我的代碼中的特定問題的問題。
這裏是我的代碼段:
activity_main.xml中:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageButton
android:id="@+id/btn_schedule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btn_facebook"
android:layout_below="@+id/btn_facebook"
android:layout_marginTop="64dp"
android:src="@drawable/schedule"
android:background="@null"
android:contentDescription="@string/none"/>
<ImageButton
android:id="@+id/btn_cfrc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/btn_schedule"
android:layout_marginLeft="73dp"
android:layout_toRightOf="@+id/btn_schedule"
android:background="@null"
android:src="@drawable/website"
android:contentDescription="@string/none"/>
<ImageButton
android:id="@+id/btn_twitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btn_cfrc"
android:layout_alignParentTop="true"
android:layout_marginTop="64dp"
android:background="@null"
android:src="@drawable/twitter"
android:contentDescription="@string/none"/>
<ImageButton
android:id="@+id/btn_facebook"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/btn_twitter"
android:layout_marginLeft="64dp"
android:background="@null"
android:src="@drawable/facebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/none"/>
</RelativeLayout>
Main_Activity.java:
package com.example.cfrcradio;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn1 = (Button) findViewById(R.id.btn_twitter);
btn1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
myWebLink.setData(Uri.parse("http://www.twitter.com/CFRC"));
startActivity(myWebLink);
}
});
Button btn2 = (Button) findViewById(R.id.btn_facebook);
btn2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
myWebLink.setData(Uri.parse("http://www.facebook.com/cfrc.kingston
fref=ts"));
startActivity(myWebLink);
}
});
Button btn3 = (Button) findViewById(R.id.btn_cfrc);
btn3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
myWebLink.setData(Uri.parse("http://www.cfrc.ca/blog/"));
startActivity(myWebLink);
}
});
Button btn4 = (Button) findViewById(R.id.btn_schedule);
btn4.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
myWebLink.setData(Uri.parse("http://www.cfrc.ca/blog/programming/schedule"));
startActivity(myWebLink);
}
});
}
}
清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.cfrcradio"
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.cfrcradio.MainActivity"
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>
請幫幫忙! !
發表您的logcat輸出,請 – lelloman