I have some trouble with fragment I got an error that says:
Binary XML file line #2 Error: inflating class fragment.
Cause by: Java.lan.NullPointerException: name == null
This is my binary file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/fragment_content"
android:name="com.livetrekker.fragments.WelcomeFragment"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
Then my FragmentActivity:
public class SetupWizard extends FragmentActivity{
public void onCreate(Bundle bundle){
super.onCreate(bundle);
setContentView(R.layout.activity_wizardsetup);
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
WelcomeFragment wf = new WelcomeFragment();
fragmentTransaction.add(R.id.fragment_content, wf);
fragmentTransaction.commit();
}
}
And Finally my fragment:
Public class WelcomeFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
return inflater.inflate(R.layout.welcomelivetrekker,container, false);
}
}
I have imported the Android.support.v4.app.Fragment to both of my file and check out on the internet, but none of the solution is working.
Your activity_wizardsetup.xml should look something like this:
Then your fragment_content.xml should look something to this effect:
I believe that should fix it… in my code i use a FragmentPagerAdapter rather than FragmentTransaction or FragmentManager… but i think fixing the xml up will work…