0

I have a tablayout with 2 tabs. this is what i do while testing. loding the first tab, then go to the second, then back the the first. on this point I get an error. but dont know how to fix it. I am a beginner in this. I hope someone can help me.

loading the fragment : https://www.dropbox.com/s/2zbmhisuwn0cezf/Screenshot_2014-12-29-17-00-27.png?dl=0 (so after going to appointments and back to profiel, the application stops working)

the error

12-29 16:41:25.959: E/AndroidRuntime(20992): FATAL EXCEPTION: main
12-29 16:41:25.959: E/AndroidRuntime(20992): Process: kb50.appointment, PID: 20992
12-29 16:41:25.959: E/AndroidRuntime(20992): android.view.InflateException: Binary XML file line #57: Error inflating class fragment
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at kb50.appointment.Profile.onCreateView(Profile.java:32)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1302)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:729)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at kb50.appointment.TabLayout.onTabChanged(TabLayout.java:132)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:453)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.widget.TabHost.setCurrentTab(TabHost.java:438)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:161)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:549)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.view.View.performClick(View.java:4756)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.view.View$PerformClick.run(View.java:19749)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.os.Handler.handleCallback(Handler.java:739)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.os.Handler.dispatchMessage(Handler.java:95)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.os.Looper.loop(Looper.java:135)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.app.ActivityThread.main(ActivityThread.java:5221)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at java.lang.reflect.Method.invoke(Native Method)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at java.lang.reflect.Method.invoke(Method.java:372)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
12-29 16:41:25.959: E/AndroidRuntime(20992): Caused by: java.lang.IllegalArgumentException: Binary XML file line #57: Duplicate id 0x7f060008, tag null, or parent id 0xffffffff with another fragment for kb50.appointment.ProfielListFragment
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2120)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.app.Activity.onCreateView(Activity.java:5282)
12-29 16:41:25.959: E/AndroidRuntime(20992):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
12-29 16:41:25.959: E/AndroidRuntime(20992):    ... 26 more
12-29 16:41:27.150: I/Process(20992): Sending signal. PID: 20992 SIG: 9

profiel.java

public class Profile extends Fragment{
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        if (container == null) {
            return null;
        }


        return (LinearLayout)inflater.inflate(R.layout.profile_layout, container, false);
    }

profielListFragment.java (with test data )

public class ProfielListFragment extends ListFragment {


    //temp data
    String[] nameApp = new String[] {
        "docter",
        "school"};
    String[] dateApp = new String[]{
        "2 september 2015",
        "3 september 2015"};
    String[] timeApp = new String[]{
            "9:00 pm",
            "8:00 am"};
    //end temp data

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {

        // Each row in the list stores country name, currency and flag
        List<HashMap<String,String>> aList = new ArrayList<HashMap<String,String>>();

        for(int i=0;i<2;i++){
            HashMap<String, String> hm = new HashMap<String,String>();
            hm.put("name", "name : " + nameApp[i]);
            hm.put("date","date : " + dateApp[i]);
            hm.put("time","time : " + timeApp[i]);

            //hm.put("flag", Integer.toString(flags[i]) );
            aList.add(hm);
        }

        // Keys used in Hashmap
        String[] from = { "name","date","time" };
        // Ids of views in profiellistfragment_layout
        int[] to = { R.id.name,R.id.date,R.id.time};

        // Instantiating an adapter to store each items
        // R.layout.profiellistfragment_layout defines the layout of each item
        SimpleAdapter adapter = new SimpleAdapter(getActivity().getBaseContext(), aList, R.layout.profiellistfragment_layout, from, to);

        setListAdapter(adapter);

        return super.onCreateView(inflater, container, savedInstanceState);
    }


}

profile_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#000000" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="0.4"
        android:background="#0000FF"
        android:orientation="horizontal" >

        <ImageView
            android:layout_width="150dp"
            android:layout_height="150dp"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="10dp"

            android:layout_gravity="top"
            android:adjustViewBounds="true"

            android:contentDescription="@string/ProfielPic"
            android:src="@drawable/pq" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" 
            android:layout_marginLeft="20dp"
            android:layout_marginTop="20dp">
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" 
                android:text="@string/userName"
                android:textColor="#FFFFFF"/>
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" 
                android:text="@string/userEmail"
                android:textColor="#FFFFFF"/>
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/userPhone"
                android:textColor="#FFFFFF" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="0.6" 
        android:background="#FF0000">

          <fragment
        android:id="@+id/First2Appointments"
        android:name="kb50.appointment.ProfielListFragment"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
            />

        <!-- <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent" 
            android:id="@+id/simple_list_item_1">

        </ListView> 

    </LinearLayout>

</LinearLayout>

profiellistfragment_layout.xml

<?xml version="1.0" encoding="UTF-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

     <TextView
        android:id="@+id/name"
        android:layout_width="0dp"
        android:layout_weight="0.4" 
        android:layout_height="wrap_content"
        android:textSize="15sp" 
        android:paddingTop="10dp"
        android:paddingRight="10dp"
        android:paddingBottom="10dp"/>


    <LinearLayout
        android:layout_width="0dp"
        android:layout_weight="0.6" 
        android:layout_height="100dp"
        android:orientation="vertical" 
        android:padding="10dp"

        >

        <TextView
            android:id="@+id/date"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="15sp" />

        <TextView
            android:id="@+id/time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="15sp" />

    </LinearLayout>

</LinearLayout>
  • Did you check this message "Binary XML file line #57: Duplicate id 0x7f060008"? It seems duplicate ID causing this issue. Check your XML files and avoid duplicate. – kosa Dec 29 '14 at 16:10
  • I removed 1 duplicate, but it is still not working. – Kelly Mies Dec 29 '14 at 16:19
  • "still not working" could be different issue. Are you still seeing that exception? If so, please update question with exception stack. – kosa Dec 29 '14 at 16:21
  • Yes it is the same, it happens on the reloading of the tab fragment. Caused by: java.lang.IllegalArgumentException: Binary XML file line #57: Duplicate id 0x7f06000b, tag null, or parent id 0xffffffff with another fragment for kb50.appointment.ProfielListFragment – Kelly Mies Dec 29 '14 at 16:24
  • 1) From that message it is clear your fragment code using duplicate Id, make sure it is fixed 2) Make sure your changes are saved – kosa Dec 29 '14 at 16:26

1 Answers1

0

I found the solution. in the answer from Vidar Wahlberg on :

Duplicate ID, tag null, or parent id with another fragment for com.google.android.gms.maps.MapFragment

my parent was NULL

Community
  • 1
  • 1