0
J'ai ceci:Je ne peux rien faire avec une vue non nulle
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);
Mais rien ne se passe.
Je vérifie si l'une des vues est nulle via une instruction if
, mais elle n'est pas nulle.
est ici la méthode complète:
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();
}
je peux mettre avec succès une vue personnalisée dans la boîte de dialogue, mais je ne peux pas modifier les vues. Pourquoi?
est ici la mise en page:
<?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"/>
Qu'entendez-vous par changement? –
@NigamPatro Je ne peux pas changer la visibilité, définir la couleur d'arrière-plan, faire fondamentalement quelque chose avec elle –
Vous devez créer votre boîte de dialogue personnalisée au lieu d'utiliser une bibliothèque. –