经过大量搜索后,我找到了该问题的各种解决方案,但该解决方案不适用于我。我使用此链接 ,但不适用于我,我也使用此链接,它也不适用于我。请帮我 。我完全被困在这里。
我使用以下代码:从我称为这样的对话框的活动中:
FirstStartDialog dialog=new FirstStartDialog(this);
dialog.show();
然后我的 Dialog 类是这样的:
public class FirstStartDialog extends AlertDialog{
public FirstStartDialog(final MainWindow mainWindow,
) {
super(mainWindow);
}
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.new_account_dialog);
//getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
editText_registration_username = (EditText) findViewById(R.id.etxt_User_Name);
editText_registration_password = (EditText) findViewById(R.id.etxt_Password);
_btn_registration_next = (Button) findViewById(R.id.btn_registration_next);
_tap_here_registration = (TextView) findViewById(R.id.txt_Tap_Here_Message);
_relative_Main_new_Account = (RelativeLayout) findViewById(R.id.relative_Main_New_Account);
editText_login_username = (EditText) findViewById(R.id.etxt_Existing_User_Name);
editText_login_password = (EditText) findViewById(R.id.etxt_Exiting_User_Password);
_btn_login_next = (Button) findViewById(R.id.btn_login_next);
_tap_here_login = (TextView) findViewById(R.id.txt_Tap_Here_Existing);
_relative_Main_Existing_Account = (RelativeLayout) findViewById(R.id.relative_Main_Existing_Account);
editText_registration_username.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
FirstStartDialog.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
});
editText_registration_password.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
FirstStartDialog.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
});
}
}
在 xml 文件中,我像这样定义我的 EditText:
<EditText
android:id="@+id/etxt_Password"
android:layout_width="210dp"
android:layout_height="22dp"
android:layout_marginTop="5dp"
android:hint="Password"
android:paddingLeft="8dp"
android:textColor="@android:color/black"
android:paddingRight="8dp"
android:textCursorDrawable="@null"
android:gravity="center_vertical"
android:textSize="12sp"
android:layout_below="@+id/etxt_User_Name"
android:layout_centerHorizontal="true"
android:background="@drawable/login_new_account_editbox"
/>
请帮我。