rodzicjak uzyskać dostęp do elementów interfejsu użytkownika w działalności macierzystej z fragmentem
<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>
nadmuchania fragmentu w działalności macierzystej onCreate funkcji
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment scannerFragment = new ScanFragment();
fragmentTransaction.add(R.id.fragment_container, scannerFragment);
fragmentTransaction.commit();
działa doskonale do tej pory ... teraz jak mogę ukryć pasek postępu? To co próbowałem
otrzymuję wyjątku null pointer
Dzięki, to działa! – Matt
Dzięki, znalazłem to po godzinach poszukiwań. – LvN
Co z możliwym NPE z 'getActivity()'? –