0
Ich habe dies:ich kann nichts tun, mit einem Nicht-Null-Ansicht
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);
Aber nichts passiert.
Ich überprüfe, ob eine der Ansichten Null über eine if
-Anweisung ist, aber es ist nicht null.
Hier ist die vollständige Methode:
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();
}
ich erfolgreich eine benutzerdefinierte Ansicht in den Dialog setzen kann, aber ich kann nicht die Ansichten ändern. Warum?
Hier ist das Layout:
<?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"/>
Was meinst du mit Änderung? –
@NigamPatro Ich kann die Sichtbarkeit nicht ändern, die Hintergrundfarbe einstellen, grundsätzlich nichts damit anfangen –
Sie müssen dann Ihren eigenen Dialog erstellen, anstatt eine Bibliothek zu verwenden. –