实现多个输入框的dialog

需要一个布局




    

    

        
    

    

    


一段代码

protected void showAddDialog() {

		LayoutInflater factory = LayoutInflater.from(this);
		final View textEntryView = factory.inflate(R.layout.dialog, null);
		final EditText editTextName = (EditText) textEntryView.findViewById(R.id.editTextName);
		final EditText editTextNumEditText = (EditText)textEntryView.findViewById(R.id.editTextNum);
		AlertDialog.Builder ad1 = new AlertDialog.Builder(FriendActivity.this);
		ad1.setTitle("增加联系人:");
		ad1.setIcon(android.R.drawable.ic_dialog_info);
		ad1.setView(textEntryView);
		ad1.setPositiveButton("是", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int i) {
				
				Log.i("111111", editTextName.getText().toString());
				PersonService personService = new PersonService(
						FriendActivity.this.getBaseContext());
				Person person = new Person();
				person.setName(editTextName.getText().toString());
				person.setPhoneNumber(editTextNumEditText.getText().toString());
				personService.save(person);

			}
		});
		ad1.setNegativeButton("否", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int i) {

			}
		});
		ad1.show();// 显示对话框

	}


你可能感兴趣的:(Java,Android)