我太累了,找不到错误。我没有发现任何错误,但我没有从 editText 收到任何文本。请看下面的代码:
活动密码.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter PIN "
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/pwdValue"
android:layout_width="match_parent"
android:maxLength="4"
android:maxLines="1"
android:inputType="numberPassword"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
我打了电话立即锁定(此); on onCreate的方法主要活动
public void LockImmediately(Context context) {
if (lock_app) {
View myview = LayoutInflater.from(context).inflate(R.layout.activity_pwd,null);
enterPWD = (EditText) myview.findViewById(R.id.pwdValue);
AlertDialog alertDialog = new AlertDialog.Builder(this).setCancelable(false)
.setView(R.layout.activity_pwd).setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String user_text = enterPWD.getText().toString();
Log.d("onCreate pws", " i "+user_text);
if (pwd.equals(user_text)) {
dialog.dismiss();
Log.d("onCreate", "Work done");
} else {
dialog.dismiss();
MainActivity.this.finish();
}
}
}).create();
alertDialog.show();
}
}
Log.d
02-15 23:15:30.840 29379-29379/com.developersqueen.wishlater D/onCreate: onCreate
02-15 23:15:37.021 29379-29379/com.developersqueen.wishlater D/onCreate pws: i
02-15 23:15:45.427 29379-29379/com.developersqueen.wishlater D/onCreate: onCreate
02-15 23:15:49.026 29379-29379/com.developersqueen.wishlater D/onCreate pws: i
您可以看到上面的日志,我已将 edittext 值与“i”连接起来,但它没有返回任何值。我尝试过清除数据、卸载应用程序、清理、构建所有内容,但结果始终相同!任何帮助,将不胜感激..