2013-03-15 2 views
0

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> 

이 도와주세요 여기

내 코드에 대한 부분입니다! !

+1

이 – lelloman

답변

0

ButtonImageButton은 동일하지 않습니다. ImageButton은 실제로 ImageView이 아니고Button이됩니다.

ClassCastException은 현재 구현되어 있어야합니다.

귀하의 경우, 모든 발생을 Button으로 변경해야하므로 ImageButton이됩니다. 예를

를 들어
Button btn1 = (Button) findViewById(R.id.btn_twitter); 

ImageButton btn1 = (ImageButton) findViewById(R.id.btn_twitter); 
+1

덕분에 당신의 로그 캣 출력을하시기 바랍니다 게시 너무 많은 지금 완벽하게 작동해야합니다! –

+0

@ShannonNeville 제 대답으로 문제가 해결되었으므로 빈 대답을 클릭하여 내 대답을 받아 들여야 녹색이됩니다. –

관련 문제