I am aware of this article 
(http://developer.android.com/guide/topics/resources/runtime-changes.html) 
and the possibilities to handle runtime changes. Nevertheless I am a bit 
stuck, I didn't make it to prevent my layout below from getting reset when 
the screen orientation changes. I add 2 buttons programatically, 1 button 
is added in the onCreate()-method, 1 button is added in a checkbox' event 
listener. And that's the one that disappears when the screen orientation 
changes. How can I prevent this?

Screenshot here: http://s14.directupload.net/file/d/2931/zvqkubis_png.htm

Regards,
-Steffen-

---

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_menu);

    ViewGroup layout = (ViewGroup) findViewById(R.id.layout);
    Button btn = new Button(getApplication());
    btn.setId(1);
    btn.setText("Button 1");
    layout.addView(btn);

    mCheckBox1 = (CheckBox) findViewById(R.id.menu1);
    mCheckBox1.setOnClickListener(mClickListener);
}

final OnClickListener mClickListener = new OnClickListener() {
    public void onClick(View v) {

        ViewGroup layout = (ViewGroup) findViewById(R.id.layout);
        Button btn = new Button(v.getContext());
        btn.setId(2);
        btn.setText("Button 2");
        layout.addView(btn);
    }
};


-- 
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

Reply via email to