사용자에게 그의 이름을 묻는 DialogFragment
을 표시하려고하는데이 문자열을 주요 활동으로 되돌려 보내야합니다.DialogFragments 및 활동, 정보 전달
: 긍정적 인 버튼의 사용자 클릭에 대한 응답으로, 내 코드에서 http://developer.android.com/guide/topics/ui/dialogs.html#CustomLayout
을, 나는 나의 주요 활동에 함수를 호출 할 수 있어요 :
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
builder.setView(inflater.inflate(R.layout.textdialog, null)).setPositiveButton("OK", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int id) {
((mainActivity)getActivity()).doPositiveClick();
}
}).setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
((mainActivity)getActivity()).doNegativeClick();
}
});
return builder.create();
}
R.layout.textdialog은 여기서
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/textdraw"
android:inputType="textEmailAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="4dp"
android:hint="introduce text" />
</LinearLayout>
내 질문입니다 내 대화 조각에서 사용자가 작성한 텍스트를 얻을 수있는 방법과 내 주요 활동으로 다시 보냅니 까?
감사합니다.
감사합니다,이 솔루션은 의미가 잘 작동합니다. – henry000