안녕하세요 초보 안드로이드 개발자입니다
현재 커스텀 다이얼로그에서 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>