好吧,所以我有一個警報對話框,顯示一個Edittext請求活動中的密碼。一切工作正常我也嘗試使用一個簡單的佈局文件。現在的問題是,每當我嘗試強制執行數字輸入時,它都會顯示數字輸入,但拒絕顯示正在輸入的任何數字輸入,同時在日誌中顯示空白字符串。它可以正常工作。但也有一個奇怪的問題,如果你輸入的第一個字符是數字,那麼它仍然有同樣的問題,但如果你輸入一些非整數字符,然後數字,那麼它是好的例如。 a5是好的,但如果你輸入5,然後山姆問題,當你特別強制執行android:inputType =「number」 現在,當我在常規活動(作爲一個完整性檢查)嘗試這個工作正常不只是在alertDialogAndroid提醒對話框數字輸入
這裏是相關代碼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/password_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="Password"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/password"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:capitalize="none"
android:gravity="fill_horizontal"
android:password="true"
android:textAppearance="?android:attr/textAppearanceMedium"/>
</LinearLayout>
public void passwordChecker() {
// TODO Auto-generated method stub
//final EditText input = new EditText(PrivacyActivity.this);
//input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
//input.setInputType(InputType.TYPE_CLASS_NUMBER);
//input.setInputType(InputType.TY);
//input.setTransformationMethod(PasswordTransformationMethod.getInstance());
LayoutInflater factory = LayoutInflater.from(mContext);
final View view = factory.inflate(R.layout.password, null);
final EditText mPassword=(EditText) view.findViewById(R.id.password);
//final EditText test=(EditText) findViewById(R.id.password);
final EditText input = new EditText(mContext);
if(true){
new AlertDialog.Builder(PrivacyActivity.this).setMessage("Enter the password")
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
//perform deletion from database
dialog.cancel();
Log.e("error", "Apple "+ mPassword.getText().toString());
}
}).setView(input)
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
....
}
}).create().show();
}
}
android:inputType =「number」在你的edittext xml中試試這個,讓我知道發生了什麼。 – user370305
嘿,我說我有那個BU輸入不顯示(數字鍵盤顯示)也沒有,因爲當我做gettext沒有什麼在那裏 – neelabh