Am Donnerstag, 30. Januar 2014 00:01:56 UTC+1 schrieb TreKing:
>
> You are creating a new Dialog in your onCreate method. onCreate gets 
> called both the first time the app is run (with savedInstanceState set to 
> null) and after an orientation (configuration) change, with 
> savedInstanceState set to the last saved state Bundle.
>
> In the latter case, the system also automatically re-creates the original 
> dialog fragment as part of the lifecycle. Therefore, the system is 
> recreating the dialog for you and you are additionally creating a new 
> instance.
>
> You explicitly check if the dialog already exists in the fragment manager, 
> which would be the original instance with the text before orientation 
> change, and you replace it with the new instance, which would be brand new 
> and not have the text saved from the original.
>
> The simple solution here is to remove checking if the dialog already 
> exists and just only create the dialog if savedInstanceState is null.
>

Thanks for your message and efforts with my problem. I am really thankful 
for that.
I've in this example neglect that onCreate() behave as you mentioned. I've 
adjusted to code and shows like this just for testing:

public class DialogTestActivity extends Activity implements OnClickListener 
{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog_test);
        ((Button) findViewById(R.id.button1)).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        AskForNameDialog d = AskForNameDialog.newInstance(new 
OnNameSetListener() {

            @Override
            public void onNameSet(AskForNameDialog dialog, String name) {
            }

        }, getString(R.string.enter_manufacturers_name));
        d.show(getFragmentManager(), "dialog");
    }

}
 
added a simple button (layout omitted here just linear with a button) and 
this should open the dialog. It behaves exactly in the same manner as 
already mentioned.
I have tried really all the stuff i found belonging to my problem, read the 
android developer blog about this, and all this really not solve this.

Thank you for your help
Daniel

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to