This is important: using tabbed activity (deprecated) everything works fine with my code, this problem only comes when I use fragments.
I have three tabs, where each tab is a fragment. Layout is the same for every tab:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridView android:id="@+id/newsView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:verticalSpacing="2dp"
android:numColumns="auto_fit"
android:gravity="center"
android:columnWidth="100dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_weight="1"/>
</LinearLayout>
Difference is for cursor loader’s query.
Each fragment, indeed, implements LaderCallbacks:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if(container == null)
return null;
View v = inflater.inflate(R.layout.activity_grid, container,false);
dataSource = new MyCursorAdapter(getActivity().getApplicationContext(), null);
GridView grid = (GridView)v.findViewById(R.id.newsView);
grid.setAdapter(dataSource);
getActivity().getSupportLoaderManager().initLoader(LOADER_ID, null, this);
return v;
and for the rest of the code (cursor query for example) I’m 100% sure, as it worked before switching to fragments.
Any ideas?
Solved…it was just another programming error, nothing wrong with the code posted..sorry!