0
我想知道如何從popupwindow中的editText框中獲取輸入。我嘗試了2種方法。一個與佈局充氣機和一個沒有,但我要麼得到「」或空,即使我輸入的東西入禁區從PopUpWindow獲取editText輸入
這一個返回「」:
// get the username and password inputs
View inflatedView = getLayoutInflater().inflate(R.layout.login_popup, null);
EditText usernameInput = (EditText) inflatedView.findViewById(R.id.username_login_input);
EditText passwordInput = (EditText) inflatedView.findViewById(R.id.password_login_input);
final String usernameString = usernameInput.getText().toString();
final String passwordString = passwordInput.getText().toString();
這一個返回null:
// get the username and password inputs
EditText usernameInput = (EditText) findViewById(R.id.username_login_input);
EditText passwordInput = (EditText) findViewById(R.id.password_login_input);
final String usernameString = usernameInput.getText().toString();
final String passwordString = passwordInput.getText().toString();
我試圖從中無法從活動
這是代碼是從
產生login_popup.xml得到它編輯
LayoutInflater layoutInflater =
(LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.login_popup, null);
ppw = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
ViewGroup parentLayout = (ViewGroup) findViewById(R.id.title_page_layout);
// set the position and size of popup
ppw.showAtLocation(parentLayout, Gravity.CENTER, 10, 20);
請張貼更多關於上下文的代碼。這段代碼在哪裏出現?在AlertDialog中?在DialogFragment中? – Karakuri 2013-05-13 21:41:55
你可以編輯你的文章... – Karakuri 2013-05-13 21:44:37