java-Android-executePendingTransactions无法从静态上下文引用

java-Android-executePendingTransactions无法从静态上下文引用,第1张

概述我从this知道Ifyouwanttoimmediatelyexecutinganysuchpendingoperations,youcancallthisfunction(onlyfromthemainthread)todoso.但是,如果我从静态主线程调用它,则会收到一条错误消息,指出executePendingTransactions()是非静态的,无法从静态上下文

我从this知道

If you want to immediately executing any such pending operations, you can call this function (only from the main thread) to do so.

但是,如果我从静态主线程调用它,则会收到一条错误消息,指出executePendingTransactions()是非静态的,无法从静态上下文中引用.

我该如何解决?

谢谢!

解决方法:

executePendingTransactions()是FragmentManager上的常规非静态方法.您需要FragmentManager的实例,例如通过在Activity或Fragment上调用getFragmentManager()(如果正在使用片段反向端口,则调用getSupportFragmentManager()).

总结

以上是内存溢出为你收集整理的java-Android-executePendingTransactions无法从静态上下文引用全部内容,希望文章能够帮你解决java-Android-executePendingTransactions无法从静态上下文引用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1089208.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存