Hmmm...
Then I suggest that you do something like this
Have the same Activity class but create 2 different classes that
behaves differently for portrait and landscape that implements a
common interface. And do something like this.
public interface ActivityDelegator {
// Put methods here that you need. I would suggest similar
lifecyle methods in the activity.
void onCreate(Bundle bundle);
void onDestroy();
...
}
public class MyActivity extends Activity {
....
private ActivityDelegator mDelegator;
...
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
boolean isLandscape =
getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE;
if (isLandscape) {
mDelegator = new LandscapeDelegator(this); // should
probably pass in this activity since you would need to use the
context.
} else {
mDelegator = new PortraitDelegator(this);
}
mDelegator.onCreate(savedInstance);
}
...
}
I am sure you know what to do from here :)
I have not investigated a better way to do this yet. But it be
sufficient to handle your requirement.
On Mar 12, 2:56 am, ailinykh <[email protected]> wrote:
> I mean different behavior. In portrait mode I have one list and a
> bunch of list oriented actions (add item, delete item)
> In landscape mode I have two lists (one on left side, another on
> right), so actions involve two lists (copy, move)
>
> On Mar 11, 10:25 am, Makas Tzavellas <[email protected]>
> wrote:
>
> > Are you just referring to just different layout or even different
> > behavior?
>
> > Because if it's just different layout, you can always use the
> > different layout folders to manage the layouts. E.g. "layout-land" in
> > for landscape layout and the default "layout" folder for portrait.
>
> > More info
> > athttp://developer.android.com/guide/topics/resources/resources-i18n.ht....
>
> > On Mar 11, 11:02 pm, ailinykh <[email protected]> wrote:
>
> > > Hello, everybody!
> > > I have two activities, one per orientation - PortraitActivity and
> > > LandscapeActivity. They are pretty much different, I can't use one
> > > Activity with different layouts.
> > > If user changed orientation I have to shutdown one of them and start
> > > another.
> > > What is the best way to manage them? Does it make sense to create
> > > GroupActivity? Or each Activity should check if the current
> > > orientation is what it needs? If so, is it save to start new Activity
> > > in onCreate method of previous one (which is not actually created
> > > yet)?
>
> > > Thank you,
> > > Andrey
>
>
--
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