- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在开发一个使用 fragment 的应用程序,上周我的测试设备进行了 lolipop 更新。当我在 Lollipop 设备上测试我的应用程序时,我发现 Fragment Transaction 的替换方法无法正常工作。
虽然在 Kitkat 版本上一切正常,但它在 Lolipop 版本中令人困惑。
为了解释我的情况,我添加了一些图片。
--第一个屏幕----------------------------KitKat---------------- ---------------------- Lollipop ----------------
如您所见,当我使用 kitkat
时,一切都很好,但是当我使用 lolipop
时, fragment 事务替换就开始困惑了。
这是我的按钮代码;
mButtonOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FeedbackFragment mFragmentFeedBack = new FeedbackFragment();
android.app.FragmentManager fm = getFragmentManager();
fm.executePendingTransactions();
android.app.FragmentTransaction fragmentTransaction = fm.beginTransaction();
if (mFragmentFeedBack.isVisible()) {
fragmentTransaction.hide(mFragmentFeedBack);
} else {
if (!mFragmentFeedBack.isAdded()) {
fragmentTransaction.replace(R.id.containerfragment, mFragmentFeedBack);
}
fragmentTransaction.show(mFragmentFeedBack);
}
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
});
这是我的xml;
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="117dp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/containerfragment">
</FrameLayout>
编辑: Kitkat 版本在平板电脑上运行,但我在手机(Kitkat 版本)上尝试了我的应用程序,结果是一样的。没有变化。
谢谢。
最佳答案
可能的问题可能是代码:
if (mFragmentFeedBack.isVisible())
我不建议使用这种方法来检查可见性。根据文档 @ Fragment isVisible() , 它说
...This means it: (1) has been added, (2) has its view attached to the window, and (3) is not hidden.
这部分句子不是很清楚。我怀疑 KitKat 说它不可见,但 Lollipop 说它是,我同意 Lollipop 的实现。 KitKat 说添加了 fragment (是的),附加了 View (是的),隐藏了(不是真的!)。不管你信不信,这实际上是其他 GUI 库的 GUI 问题!
可能的解决方案,目前:
关于android - API-21 上的 Fragment 事务替换处于落后状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30731107/
let config = [{ name: 1, state: 1, output: 'Y', }, { name: 2, state: 1, outp
我在使用 C# 统一编程时遇到了一些问题。我试图在开始游戏时请求一个插页式广告,这样我就可以在玩家死亡 5 次时显示它。问题是,当我遇到第 5 次死亡时,广告将不会显示。当我尝试在关卡开始时请求广告时
我有 JPanel,从中打开一个扩展 AbstractAIFDialog 的搜索条件对话框。它由搜索条件文本字段、结果 TableView 和搜索按钮组成。单击“搜索”后,在此对话框中,我需要显示进度
所以,我的蛇做了连续的运动,但如果我按任意键,它就会及时倒退并前后滞后。这是视频:https://youtu.be/KCesu5bGiS8 我的猜测是更快地更新按键输入,但是当我这样做时,所有内容都会
我正在尝试获得 TODAY THE CURRENT 的所有选票,并且我几乎已经通过以下 mysql 查询实现了这一点,但是有一个问题。 这段代码让我获得了今天的选票: SELECT COUNT(*)
我正在使用 RS256 算法生成 Azure AD token 。 当我解码 https://jwt.io/ 中的 token 时发出的时间比请求时间晚了 5 分钟。 请求的时间:美国标准时间晚上 9
当我查询 NOW() 时,mysql 返回的时间与服务器上的当前时间相差大约 -30 秒。有任何想法吗?我尝试查看配置文件,但一无所获。我正在运行 5.1.37 版本 SELECT NOW() 最佳答
我正在做一个开源项目。我首先 fork 这个项目,将它克隆到我的机器上,然后直接在 master 分支上进行了更改。我提交了这些更改并将其推到我的 fork 上。然后我打开了该更改的 pull 请求。
所以我用了大约 20 分钟写出了这个程序,并花了最后 40 分钟绞尽脑汁地想为什么它返回 21131 而不是 21124,这似乎是正确的答案。我知道代码没有问题(很可能),因为它适用于我测试的每个数字
我在使用 QueryDsl 日期算法时遇到问题。它对我不起作用,会引发以下错误: Caused by: org.postgresql.util.PSQLException: ERROR: functi
嗨,我正在玩 Angular ui 时间选择器 http://angular-ui.github.io/bootstrap/ 当我使用它时,我的日期晚了 1 小时,我该如何更改它以及为什么? JS
我是一名优秀的程序员,十分优秀!