English 中文(简体)
一. 方向变化时的谋杀
原标题:Kill an activity when orientation changes
  • 时间:2011-10-15 16:40:23
  •  标签:
  • android

我愿知道,在方向变化时,能否要求安乐施不要重载一项活动(我想重载他人,但把这 !)。

我已经检查了我可以列入清单的活动性质,但似乎没有人允许这样做。

感谢!

最佳回答

为此:

public boolean onRetainNonConfigurationInstance() {
    return true;
}

public onCreate() {
    if(getLastNonConfigurationInstance() != null) {
        finish();
    }
}
问题回答

很简单,在你的活动中,它凌驾于onConfiguration 改动(建筑群),并在其中杀死有关活动。

    @Override
    public void onConfigurationChanged (Configuration newConfig)
    {
          super.onConfigurationChanged(newConfig);
          finish();
    }

这将使活动在组合发生变化时丧生。 在选择了你的活动方向。 你们可以检查一下它正在改变的哪类方向,看看看新的复杂情况,并把它与混杂类的孔隙和景观相提并论。

我愿知道,在方向变化时,能否要求安乐施不要重载一项活动(我想重载他人,但把这 !)。

Possible? Sure. A good idea? No. Users will get very confused if a simple twist of their wrist causes the current activity to go away. They might think that your app is broken.

理想的做法是,允许用户以他们想要的任何方向利用你的活动。 这不是你。

如果出于某种原因,某些活动只在一种方向(例如景观)中具有意义,则使用<代码>android:orientation <>/code>vide in the <>s in the expression,以保持这一方向。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签