Q:

ListFragment The specified child already has a parent

in my app i have a tabbed layout (4 tabs) with a ViewPagerAdapter for switch from on tab to another, in all the tabs i'm implementing ListFragment, because i need to load data from SQLite and show the rows.  The rows are loaded but when i try to switch to another tab the app crashes with the following message:
java.lang. IllegalStateException: The specified child already has a parent.  You must call removeView() on the child's parent first. 

So i've searched for this error and i've found solution like:
v = inflater.inflate(R.layout.tab_1_list, container, false);
v = inflater.inflate(R.layout.tab_1_list, null);

But doesn't works, the error is still the same
ViewPagerAdapter
import android.support.v4.app. Fragment;
import android.support.v4.app. FragmentManager;
import android.support.v4.app. FragmentStatePagerAdapter;
import android.content. Context;

public class ViewPagerAdapter extends FragmentStatePagerAdapter {

CharSequence Titles[]; // This will Store the Titles of the Tabs which are Going to be passed when ViewPagerAdapter is created
int NumbOfTabs; // Store the number of tabs, this will also be passed when the ViewPagerAdapter is created
private Context context;

// Build a Constructor and assign the passed Values to appropriate values in the class
public ViewPagerAdapter(FragmentManager fm,CharSequence mTitles[], int mNumbOfTabsumb) {
    super(fm);

    this. Titles = mTitles;
    this. NumbOfTabs = mNumbOfTabsumb;

}

//This method return the fragment for the every position in the View Pager
@Override
public Fragment getItem(int position) {

    if(position == 0) // if the position is 0 we are returning the First tab
    {
        Tab1 tab1 = new Tab1();
        return tab1;
    } else if(position == 1){
        Tab2 tab2 = new Tab2();
        return tab2;
    } else if(position == 2) {
        Tab3 tab3 = new Tab3(); 
        return tab3;    
    } else if(position == 3) {
        Tab4 tab4 = new Tab4();
        return tab4;
    } else {
        Tab1 tab1 = new Tab1();
        return tab1;
    }
}

// This method return the titles for the Tabs in the Tab Strip

@Override
public CharSequence getPageTitle(int position) {

    return Titles[position];
}

// This method return the Number of tabs for the tabs Strip

@Override
public int getCount() {
    return NumbOfTabs;
}
}

Tab1.java
public class Tab1 extends ListFragment
{

public View v;
public String title;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.tab_1_list, container, false);

    //database handler
    DatabaseNumbersHandler db = new DatabaseNumbersHandler(getContext());
    ///get titles
    ArrayList list = db.getTitles();

    // Get a handle to the list view
    ListView lv = (ListView) v.findViewById(android. R.id.list);

    // Convert ArrayList to array
    String[] lv_arr = (String[]) list.toArray(new String[list.size()]);
    lv.setAdapter(new ArrayAdapter(getContext(), android. R.layout.simple_list_item_1, lv_arr));

    return lv;
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    //
    // insert code here to setup and call setListAdapter()
    //
    //database handler

}

@Override
public void onListItemClick(ListView lv, View v, int position, long id)
{

}
}

tab_1_list.xml
<? xml version="1.0" encoding="utf-8"? >
<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" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.tyr. MainSettings">

<ListView
    android:id="@android:id/list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
</ListView>

</RelativeLayout>

A:

Your returning ListView instead of View
Replace it
 @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        v = inflater.inflate(R.layout.tab_1_list, container, false);

        //database handler
        DatabaseNumbersHandler db = new DatabaseNumbersHandler(getContext());
        ///get titles
        ArrayList list = db.getTitles();

        // Get a handle to the list view
        ListView lv = (ListView) v.findViewById(android. R.id.list);

        // Convert ArrayList to array
        String[] lv_arr = (String[]) list.toArray(new String[list.size()]);
        lv.setAdapter(new ArrayAdapter(getContext(), android. R.layout.simple_list_item_1, lv_arr));

        return v;
    }

