2
我創造未來AlerDialog得到的EditText:如何從片段
AlertDialog.Builder alert = new AlertDialog.Builder(appContext);
alert.setTitle("Add subcontractors").setView(R.layout.add_subcontractor_form);
//final EditText input = new EditText(appContext);
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String YouEditTextValue = input.getText().toString();
}
});
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// what ever you want to do with No option.
}
});
alert.show();
而且具有未來佈局它:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<EditText
android:layout_margin="10dp"
android:id="@+id/et_sub_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Type name here"
android:textSize="20sp"/>
</LinearLayout>
我的問題是,如何從我的代碼佈局得到的EditText看法? 因爲我想在用戶按下「確定」按鈕後輸入一個文本。
大,它爲我工作。萬分感謝 – neustart47