버튼이있는 Main.xml을 만들었습니다. 그들은 모두 특정 행동을 수행하며 이것은 모두 괜찮지 만 암호로 보호 된 버튼이 있어야합니다. 그래서 두 번째 xml (popup.xml)도 만들었습니다. 사용자가 버튼을 누르면 팝업됩니다. popup.xml에는 사용자 입력을위한 텍스트 필드와 제출 버튼이 있습니다. 나는 버튼을 팝업에 눌러 순간 Android에서 팝업을 만들고 기본보기에 데이터를 제출하려면 어떻게해야합니까?
가 나타납니다,하지만 난 기본보기에 사용자가 입력 한 데이터를 제출하거나 버튼을 눌러 다시 기본보기로 이동하는 방법을 모르겠어요. 그것을 제거 할 수는dismiss()
를 호출 -
public class BastiLauncherActivity extends Activity implements OnClickListener {
private Button b1;
// ...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// this b1 is a button in the main view where this pop up should appear
b1 = (Button) findViewById(R.id.b1Button);
b1.setOnClickListener(this);
// ...
}
@Override
public void onClick(View v) {
LayoutInflater inflater =
(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.popup, null,
false), 200, 300, true);
pw.setOutsideTouchable(true);
if (v == b1) {
// opening the popup
pw.showAtLocation(findViewById(R.id.dateiButton), Gravity.CENTER, 0, 0);
} else if (...) {
}
}
}
난 당신이 채우기 위해 어떤 형태를 보여주기 위해 대화 상자를 사용할 수 있어야하며 다음의 EditText의 값, 당신의 XML file.http의에서 사용자 정의보기로 대화를 위해이 링크를 참조하는 것이 얻을 수 있다고 생각 : // 개발자 .android.com/guide/topics/ui/dialogs.html – Herry