마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

오류는 없는데 실행이 안됩니다.

0 추천
package com.example.hometown_v1;
 
import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
 
public class MainActivity extends Activity {
 
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar abar = getActionBar();
abar.show();
abar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME);
 
Button menu1 = (Button) findViewById(R.id.mybtn);
menu1.setOnClickListener(new View.OnClickListener() {
 
public void onClick(View v) {
 
}
});
 
}
}
 
여기서 setonclickListener를 사용만해도 실행이 안됩니다. 로그캣이나 어디에서도 오류나 이런게 안뜹니다 고수님들 부탁드리겠습니다. 
익명사용자 님이 2014년 8월 18일 질문

1개의 답변

0 추천
디버깅을 하시려면.. 지금 추측하고 계신 부분을 주석 처리하고도 올라오는지를 확인하세요.

지금과 같은 경우 java 소스에서 menu1 을 사용하는 부분을 모두 주석처리하고 실행해보시고

올라오는지부터 확인하세요.

안올라온다면 actionbar 부분을 주석 처리하고 menu1 사용부분은 다시 살리고,

문제가 확인이 안되면 다음으로 xml 파일들을 봐야겠네요
Gioskhan (12,060 포인트) 님이 2014년 8월 18일 답변
주석처리해보고했는데  menu1.setOnClickListener(new View.OnClickListener()이 부분만 사용시 앱이 그냥 꺼집니다
layout xml 파일 한번 올려봐주세요.
<LinearLayout 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:orientation ="vertical"
    android:gravity="center_vertical"
   >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <Button
            android:name = "@+id/mybtn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="팀관리"
            android:textSize="15sp"
            android:padding="20dp"
            android:layout_weight="5"/>
        <Button
            android:name = "@+id/listbtn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="경기목록"
            android:textSize="15sp"
            android:padding="20dp"
            android:layout_weight="5"/>
    </LinearLayout>
 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <Button
            android:name = "@+id/rankbtn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="우리동네 랭킹"
            android:textSize="15sp"
            android:padding="20dp"
            android:layout_weight="5"/>
        <Button
            android:name = "@+id/resultbtn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="경기결과"
            android:textSize="15sp"
            android:padding="20dp"
            android:layout_weight="5"/>
    </LinearLayout>
</LinearLayout>
android:name = "@+id/mybtn" 이게 아니고..
android:id="@+id/mybtn" 이요..
정말 감사합니다 ㅜㅜㅜ 제가 초보라서 정말 초보적인 짓만 하네요 ㅋㅋㅋ
건승하셔요 ㅠㅠㅠㅠㅠ
...