I defined dynamically all GUI components.When the Cntrl+F11 is first pressed the layout updates correctly to from portrait to landscape. But when I press Cntrl+F11 again, layout remains in its “landscape” look. How can I update it for “portrait” look again? The source code:
//Main Layout ll
LinearLayout ll ;
ll.setOrientation (LinearLayout.VERTICAL);
ll.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
//Inner layout ll2 is inside of the main layout ll
LinearLayout ll2 = new LinearLayout (this);
ll2.setWeight(1.0f);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
lp.weight = 0.25f;
//Button b is inside of the inner layout ll2
Button b = new Button (this);
b.setLayoutParams(lp);
ll2.addView (b);
ll.addView(ll2);
I tried this solution (from this site):
I added function
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(ll);
}
and set I in AndroidManifest
android:configChanges="keyboardHidden|orientation"
but it stiil doesn’t work.Thanks.
use this in xml file
android:orientatoin=”portrait “
it is also possible to write in onCreate() method also
You Also specify in ANDROID_MANIFEST like this