我有其中有一个片段的活动。
I have an activity which has a fragment.
XML:
<fragment android:name="com.example.androidcalculator.ResultFragment"
android:id="@+id/result_fragment"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
和我想从活动的方法调用从ResultFragment的方法,但getSupportFragmentManager不存在:
And I want to call a method from ResultFragment from a method in the Activity, but getSupportFragmentManager "doesn't exist":
FragmentManager fragMan = getSupportFragmentManager();
我该如何解决此问题?
How can I resolve this?
您的活动不会延长FragmentActivity从支持库,因此该方法不是present在超
Your activity doesn't extend FragmentActivity from the support library, therefore the method is not present in the superclass
如果你的目标API 11或以上,你可以使用Activity.getFragmentManager代替。
If you are targeting api 11 or above, you could use Activity.getFragmentManager instead.
上一篇:上后退按钮preSS的Android跳过活动跳过、按钮、Andr、preSS
下一篇:尝试重新打开一个已关闭的对象上:java.lang.IllegalStateException:?对象、java、IllegalStateException、lang