在 TabHost 内更改活动转换
我已使用 overridePendingTransition()
成功更改了活动之间的转换。
不幸的是,当我在 TabActivity
上并使用每个选项卡内的活动时。当选项卡内容中的其中一个活动启动另一个活动时,overridePendingTransition() 似乎不起作用。
我基本上有一个 TabActivity,里面有一个带有 ListView 的活动。我正在做的是,当单击该项目时,我启动项目详细信息的活动。
这个新活动的转换动画不会被 overridePendingTransition()
覆盖,
我基本上是这样做的:
private Activity owner;
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent programActivity = new Intent().setClass(view.getContext(), ProgramActivity.class);
Program program = (Program) parent.getItemAtPosition(position);
programActivity.putExtra("programID", program.getId());
owner.startActivity(programActivity);
owner.overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
所以,我相信在我尝试覆盖它们之后,挂起的转换会被覆盖。
我应该在其他地方这样做吗? 我还犯了其他愚蠢的错误吗?
谢谢 !
I have successfully changed the transitions between activities using overridePendingTransition()
.
Unfortunately when I am on a TabActivity
and use activities inside each tab. When one of those activities inside the content of the tab, starts another activity, the overridePendingTransition()
seems to not work.
I basically have a TabActivity
, inside it resides an activity with a ListView
. What I'm doing is when the item is clicked, I launch the item details' activity.
This new activity's transition animation is not being overridden with the overridePendingTransition()
I basically do this:
private Activity owner;
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent programActivity = new Intent().setClass(view.getContext(), ProgramActivity.class);
Program program = (Program) parent.getItemAtPosition(position);
programActivity.putExtra("programID", program.getId());
owner.startActivity(programActivity);
owner.overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
So, I believe that the pending transition is overridden after I'm trying to override them.
Is there a different place I should do that?
Am I doing some other stupid mistake?
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在从片段中调用 overridePendingTransition() 时遇到了类似的问题,因为片段没有定义 overridePendingTransition() 方法。
我用以下方法解决了这个问题:
希望有帮助。该片段位于 TabHost 内。
I had a similar problem with calling overridePendingTransition() from within a Fragment, because Fragments do not have overridePendingTransition() method defined.
I solved it using:
Hope it helps. The Fragment was within a TabHost.
我发现问题是因为我的视图是选项卡内的子活动。
为了正确重写转换,我重写了
TabActivity
上的onPause
方法,现在它可以按预期工作。注意:如果您的 Activity 不在选项卡内,您仍然必须在项目的侦听器上使用
overridePendingTransition()
。I found out that the problem was because my view was a sub-activity inside a tab.
To correctly override the transitions I've overridden the
onPause
method on theTabActivity
and it now works as expected.Note: You still have to use the
overridePendingTransition()
on the listener for your items if your activity is NOT within a tab.