2016-12-09 11 views
0

으로 아무것도 할 수 없어 난이 있습니다내가 널이 아닌보기

View v = getLayoutInflater().inflate(R.layout.phone_number_requester, null); 
final EditText editText = (EditText) v.findViewById(R.id.phoneNumberET); 
v.findViewById(R.id.verificationCodeET).setVisibility(View.GONE); 

을하지만 아무 반응이 없습니다.

if 문을 통해 뷰 중 null이 있는지 확인하고 있지만 null이 아닙니다.

여기에 전체 방법입니다 :

private void askForPhoneNumber(){ 
    View v = getLayoutInflater().inflate(R.layout.phone_number_requester, null); 
    final EditText editText = (EditText) v.findViewById(R.id.phoneNumberET); 
    v.findViewById(R.id.verificationCodeET).setVisibility(View.GONE); 
    final PhoneNumberUtil pnu = PhoneNumberUtil.getInstance(); 
    new MaterialDialog.Builder(this) 
      .title(R.string.requestPhoneNumber) 
      .customView(R.layout.phone_number_requester,false) 
      .cancelable(false) 
      .autoDismiss(false) 
      .positiveText(android.R.string.ok) 
      .onPositive(new MaterialDialog.SingleButtonCallback() { 
       @Override 
       public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 
        if (OK){ 
         sendSMS(); 
        } 

        else if (editText.getText().toString().trim().isEmpty()){ 
         editText.setError(getString(R.string.required)); 
        } 
       } 
      }).show(); 
    } 

내가 성공적으로 대화 상자에 사용자 지정보기를 넣을 수 있습니다,하지만 난의 의견을 변경할 수 없습니다. 왜?

여기 레이아웃입니다 :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:padding="13dp"> 

<TextView 
    android:id="@+id/textView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/phoneNumberInfo" 
    android:textSize="12sp" 
    android:textStyle="normal|italic" /> 

<com.rey.material.widget.EditText 
    android:id="@+id/phoneNumberET" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="@string/phoneNumber" 
    android:inputType="phone" 
    app:et_dividerAnimDuration="2" 
    app:et_dividerHeight="1dp" 
    app:et_helper="@string/phoneNumberHelper" 
    app:et_supportMode="helperWithError" /> 

<com.rey.material.widget.EditText 
    android:id="@+id/verificationCodeET" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:hint="@string/verificationCode" 
    android:inputType="number" 
    app:et_dividerAnimDuration="2" 
    app:et_supportMode="helper"/> 

+0

변경 사항은 무엇을 의미합니까? –

+0

@NigamPatro 가시성을 변경할 수없고, 배경색을 설정하지 못했습니다. 기본적으로 아무 것도하지 마십시오. –

+0

라이브러리를 사용하는 대신 사용자 정의 대화 상자를 만들어야합니다. –

답변

1

.customView(v, false).customView(R.layout.phone_number_requester,false)를 교체하고 그것을 작동합니다.