父活動佈局如何從片段
<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=".LockerCodeActivity" >
<LinearLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:id="@+id/ctrlActivityIndicator"
android:indeterminateOnly="true"
android:keepScreenOn="false"
/>
<TextView
android:id="@+id/tv_results"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="" />
</RelativeLayout>
充氣父活動的片段的onCreate功能
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment scannerFragment = new ScanFragment();
fragmentTransaction.add(R.id.fragment_container, scannerFragment);
fragmentTransaction.commit();
工作訪問的UI元素的父活動極大那麼遠,現在我該怎麼辦隱藏進度條? 這是我已經試過
我得到一個空指針異常
謝謝,它的工作原理! – Matt
謝謝,經過幾個小時的搜索後發現。 – LvN
來自'getActivity()'的可能的NPE怎麼樣? –