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

이미지 버튼을 누를 때 keeps stopping이 나오고 실행이 안됩니다.

0 추천

분명히 전날 밤에는 작동이 됬던것 같은데 뭘 잘못 건드렸는지 버튼이 눌려도 작동하지 않습니다. 메인 액티비티에서 다른 엑티비티로 넘어가는 버튼은 잘 작동이 되는데 이 inquiry액티비티에서 이미지 버튼들이 작동하지 않습니다. 자바에 이 버튼들을 정의하지 않아서 발생하는 문제인가 했지만 없을때도 정상적으로 작동했고 제가 넣어본 결과로는 해결되지 않았습니다. 또한 문제가 되는 이미지 버튼들을 누르면 바로 오류가 나오는 것이아니라 앱이 잠깐 멈췄다가 메인액티비티로 돌아가고 그상태에서 한번 더 누를경우 keeps stopping오류가 나옵니다.

다른 오류들을 찾아보니 주로 오타와 관련된 오류던데 제 시야가 좁은건지 오타는 보이지 않네요. 프로그래밍에 초보라 할수 잇는 학생인지라 로그캣을 보는 법을 잘 몰라서 찾기 힘든것도 있는 것 같습니다. 

아래는 순서대로 로그 캣, inquiry activity의 java파일,  inquiry activity의 layout xml파일입니다. 처음 질문을 써서 양식을 지켰는지 잘 모르겠네요. 도움을 주신다면 정말 감사하겠습니다.

 

2019-11-26 21:43:09.280 4936-4963/hs.daegun.dg_pr E/eglCodecCommon: GoldfishAddressSpaceHostMemoryAllocator: ioctl_ping failed for device_type=5, ret=-1

2019-11-26 21:43:22.719 4936-4936/hs.daegun.dg_pr E/AndroidRuntime: FATAL EXCEPTION: main
    Process: hs.daegun.dg_pr, PID: 4936
    java.lang.IllegalStateException: Could not find method onClicked1(View) in a parent or ancestor Context for android:onClick attribute defined on view class androidx.appcompat.widget.AppCompatImageButton with id 'imageButton'
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:436)
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:393)
        at android.view.View.performClick(View.java:6597)
        at android.view.View.performClickInternal(View.java:6574)
        at android.view.View.access$3100(View.java:778)
        at android.view.View$PerformClick.run(View.java:25885)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

package hs.daegun.dg_pr;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

public class inquiry_activity extends AppCompatActivity {

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

    public void onClicked1(View v){
        Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.daegun.hs.kr/user/mobile/index.do"));
        startActivity(intent);
    }

    public void onClicked2(View v){
        Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse("tel:010-6764-0807"));
        startActivity(intent);
    }

    public void onClicked3(View v){
        Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse("https://v4.map.naver.com/index.nhn?pinTitle=%EB%8C%80%EA%B1%B4%EA%B3%A0%EB%93%B1%ED%95%99%EA%B5%90&pinType=site&pinId=11556843&mapMode=0"));
        startActivity(intent);
    }
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    tools:context=".inquiry_activity">

    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:onClick="onClicked1"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.518"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/rip" />

    <ImageButton
        android:id="@+id/imageButton2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onClicked2"
        app:layout_constraintBottom_toTopOf="@+id/imageButton3"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageButton"
        app:srcCompat="@drawable/rip" />

    <ImageButton
        android:id="@+id/imageButton3"
        android:layout_width="387dp"
        android:layout_height="207dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginBottom="24dp"
        android:onClick="onClicked3"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.187"
        app:layout_constraintStart_toStartOf="parent"
        app:srcCompat="@drawable/map" />
</androidx.constraintlayout.widget.ConstraintLayout>

 

익명사용자 님이 2019년 11월 26일 질문

1개의 답변

0 추천
자답입니다. inquiry activity에는 아무런 이상이 없었고 다른 activity에서 inquiry layout을 가져가서 그 버튼이 잘 작동하지 않았던 것이고 inquiry activity에는 오류가 없었습니다. 아마 전날 되었던건 똑바로된 버튼을 작동한거고 다음날 안된건 다른 액티비티가 모양이 같아 헷갈린것 같습니다. 막상 발견하니까 엄청 창피한 오류네요 이런 질문해서 죄송합니다.
익명사용자 님이 2019년 11월 27일 답변
현재 full active 안드로이드 기본 프로젝트에서 동일한 문제가 발생하는데 더 설명 해주실 수 있으신가요?
...