I overided onConfigurationChanged() in android 2.3.3 version. When I changed Land-Scape to Portraint, its orientation is changed but from Portrait to Landscape it is not changing.
Please help me to change the orientation from Portrait to Landscape.
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
int orientation = this.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
setContentView(R.layout.settings);
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
setContentView(R.layout.settings);
}
}
Related Question
Ensure that the Manifest has following entry for the activity you are launching.
android:configChanges="orientation|keyboardHidden
On the emulator, it might happen that once you change the orientation, it will not go back to the previous one because of this bug
Related
Im finishing my activity with an animation and before android n, they worked fine but now the activity just disappears without the transition. Is this a bug or something?
#Override
public void finish() {
super.finish();
//Worked before android n
overridePendingTransition(R.anim.slide_up, R.anim.slide_down);
}
Im currently developing a basic game for Android, but I'm having a big problem with the com.badlogic.gdx.scenes.scene2d.utils library.
When I started the project I used Eclipse and the DragAndDrop-functionality worked great, but after a while I experienced problems with Gradle which led me to change to Android Studio. So after exporting my project to Android studio, the DragAndDrop just stopped working. When I click a dragobject and start to drag it, it stops immediately and DragStop() is called.
Now I feel I have tried everything there is and the only lead is this thread: https://github.com/libgdx/libgdx/issues/2901 which is basicly the same behavior, but it's caused by something else. By "lead" I mean that maybe the change of LibGDX version is the problem? I have not investigated this any further.
Anyway, I can't even get this simple DragAndDrop example to work:
dragAndDrop = new DragAndDrop();
dragAndDrop.addSource(new DragAndDrop.Source(splashActor)
{
#Override
public DragAndDrop.Payload dragStart(InputEvent event, float x,
float y,int pointer)
{
DragAndDrop.Payload payload = new DragAndDrop.Payload();
payload.setObject(splashActor);
payload.setDragActor(splashActor);
return payload;
}
});
dragAndDrop.addTarget(new DragAndDrop.Target(pauseButton)
{
#Override
public boolean drag(DragAndDrop.Source source, DragAndDrop.Payload payload,
float x, float y, int pointer)
{
return true;
}
#Override
public void drop(DragAndDrop.Source source, DragAndDrop.Payload payload,
float x, float y, int pointer)
{
}
});
Thanks for any help or ideas regarding this problem. I would be truly grateful if I could get my game working again!
This problem was fixed by updating the libgdx version to 1.5.5-SNAPSHOT! Thanks to noone for solving this.
I'm trying to decide whether to use a switch or toggle for setting an alarm I'm my android application. On fairly new to android and don't know or quite understand all the ins and outs of the frame work. What would be the disadvantages of choosing to trigger the alarm with a switch over a toggle, or vice versa? Is there a slide toggle available in android framework?
The first thing you need to keep in mind is since which API do you want to compile your app?
Toggle Buttons are available since API 1 and Switches are only available since API 14.
Besides that is just a simple decision, which one is the best option for user interface/design
In my opinion Switches give a clear indication of what is currently selected.
Is there a slide toggle available in android framework?
Yes a switch can work as a slide toggle.
The code is very simple, you can basically use the same thought for these two buttons.
Here is an example of a Switch Button
btnSwitch = (Switch) findViewById(R.id.switch_1);
btnSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
if (isChecked) {
Log.i("Switch", "ON");
} else {
Log.i("Switch", "OFF");
}
}
});
Here's an example of a toggle Button
btnToggle = (ToggleButton) findViewById(R.id.toggle_1);
btnToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Log.i("Toggle", "ON");
} else {
Log.i("Toggle", "OFF");
}
}
});
I'm currently trying to build an iOS app which is orientation sensitive - when I rotate the app, I want the view to change.
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
new UIAlertView("DEBUG", "test", null, "OK", null).Show ();
// Return true for supported orientations
if (UserInterfaceIdiomIsPhone) {
return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown);
} else {
return true;
}
}
I inserted the UIAlert to test if this is actually detected, but unfortunately not. I was wondering if I may get any advice on this please?
Apple changed the rotation api in ios6 - see Monotouch.Dialog IOS 6 Split view Rotation issue for some more help (including some MonoTouch)
I have the sample of softkeyboard. When I install it on a android 2.x, it has the following non-fullscreen view:
But when I install it on tablet 10in it gets whole of the screen like this:
How can I change the sample to have a non-fullscreen custom keyboard on tablet pcs like this image (default keyboard of tablet)?
The following code in InputMethodService solved my problem:
#Override
public boolean onEvaluateFullscreenMode() {
return false;
}
overide the following two methods from InputmethodService as bellow, this works always
#Override
public void onUpdateExtractingVisibility(EditorInfo ei) {
// TODO Auto-generated method stub
setExtractViewShown(false);
}
#Override
public boolean onEvaluateFullscreenMode() {
return false;
}
This worked for me :) and if you want to show keyboard in fullscreen mode always then change both false to true.