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

개발자 선배님들 부탁드립니다ㅜㅜ커스텀 다이얼로그에서 EditText값 가져오기가 아니되어요...

0 추천

안녕하세요 초보 안드로이드 개발자입니다

현재 커스텀 다이얼로그에서 EditText값을 가져오는데 하루종일 삽질을 했으나 도저히 진척히 없어서 이렇게 질문 드립니다ㅠㅠㅠㅠ

커스텀 다이얼로그 xml 레이아웃 이름은 dialog_point.xml 이고,

현재 MainActivity의 함수 안에서 EditText의 값을 가져오려고합니다.

아이러니하게도 커스텀 다이얼로그의 TextView 값은 잘 가져와지는데 EditText 값이 안 가져와집니다..

 

LayoutInflater linf = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
final View inflator = linf.inflate(R.layout.dialog_point, null);

memberPoint = (TextView) inflator.findViewById(R.id.memberPoint);
usePoint = (EditText) inflator.findViewById(R.id.usePoint);

String temp = memberPoint.getText().toString();
int point = Integer.parseInt(temp);
Toast.makeText(this, temp,
        Toast.LENGTH_SHORT).show();

String temp2 = usePoint.getText().toString();
Toast.makeText(this, temp2,
        Toast.LENGTH_SHORT).show();

위와 같이 짰는데 EditText는 계속 null값만 반환하더군요

TextView 인 memberPoint 값은 잘 가져와집니다 EditText인 usePoint만 null값을 반환합니다ㅠㅠ

둘 다 dialog_point.xml에 있습니다..

안드로이드 개발자 선배님들 부탁드립니다 제발 알려주세요..ㅠㅠ

구글링을 열심히 해본결과가 인플레이터였는데 왜 EditText만 못 가져 오는 걸가요..ㅠㅠㅠㅠㅠㅠㅠ

 

+) dialog_point.xml 입니다ㅠㅠ

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:id="@+id/pointLayout">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="회원 전화번호"
            android:textSize="20dp"/>

        <EditText
            android:id="@+id/memberCode"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:hint="뒤 4자리 입력"/>

        <Button
            android:id="@+id/memberFind"
            android:textSize="15dp"
            android:text="회원조회"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />

    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:text="회원 이름"
            android:textSize="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/memberName"
            android:textSize="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:text="회원 전화번호"
            android:textSize="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/memberPhone"
            android:textSize="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:text="회원 포인트"
            android:textSize="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/memberPoint"
            android:text="3000"
            android:textSize="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:text="사용할 포인트"
            android:textSize="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <EditText
            android:id="@+id/usePoint"
            android:textSize="20dp"
            android:hint="포인트 입력"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button
            android:id="@+id/Ok"
            android:text="사용하기"
            android:textSize="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/No"
            android:text="취소"
            android:textSize="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

</LinearLayout>

 

펭귄주니어 (140 포인트) 님이 2017년 12월 3일 질문
펭귄주니어님이 2017년 12월 7일 수정
코드상은 문제가 없는 듯 합니다.  dialog_point.xml ​를 올려주시는게 좋을 듯 하네요.
늦어서 죄송합니다ㅜㅜ아직까지도 해결을 못하고 있습니다..ㅠㅠㅠㅠ
댓글 감사합니다ㅠㅠ

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...