Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8970779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:47:26+00:00 2026-06-15T17:47:26+00:00

I extends the ListFragment in support lib, using a subclass of SimpleCursorAdapter as the

  • 0

I extends the ListFragment in support lib, using a subclass of SimpleCursorAdapter as the adapter. All the data loading part is ok (read via debug), the list just doesn’t show, I have a blank page on the Activity. Here is my code:

import android.support.v4.app.FragmentActivity;

public class HostActivity extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_with_fragment);
}
}

layout file (activity_view_with_fragment.xml):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical" >
    <fragment
            android:id="@+id/lsStopTimetableFragment"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginTop="?android:attr/actionBarSize"
            android:layout_weight="1"
            class="com.package.Fragment.MyFragment">
    </fragment>
</LinearLayout>

This is the ListFragment code:

import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
public class MyFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor>{
    public  void onActivityCreated(Bundle savedInstanceState){
        super.onActivityCreated(savedInstanceState);
        String [] from = new String[] {"col_1", "col_2"}; 
        int [] to = new int [] {R.id.view1, R.id.view2}; 
        //..put value in args
        Loader l = getLoaderManager().restartLoader(0, args, this);
        if(l != null)
            l.forceLoad();

        adapter = new CustomCursorAdapter(this.getActivity()
              , R.layout.row_entry, null, from,
                to, 0);
        setListAdapter(adapter);
    }
    @Override
    public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
        adapter.swapCursor(cursor);
    }
    public void onLoaderReset(Loader<Cursor> cursorLoader) {
        adapter.swapCursor(null);
    }

}

And in CustomCursorAdapter, I do implement the

getView (int pos, View convertView, ViewGroup parent)

method. Any tip? thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:47:27+00:00Added an answer on June 15, 2026 at 5:47 pm

    Have you tried to change the layout_width and layout_height parameters in fragment item from 0dp to match_parent? If you are trying to make an activity with only list fragment which fills the whole activity, you don’t need to create layout like:

    <LinearLayout>
    <fragment/>
    </LinearLayout>
    

    you can directly create layout with fragment tag as root and only tag:

    <fragment/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a SimpleCursorAdapter and a ListView to show some data loaded with a
I want do custom listview using base adapter in listfragment I try this code:
I have crated a class which extends the ListFragment . I have one button
Dataset extends ArrayList. Dataset<Pair<SRGB>> data = new Dataset<Pair<SRGB>>(); Statement stmt = this.conn.createStatement(); ResultSet rs
What I want to achieve is having a ListFragment which displays data loaded from
Okay, so I've got FavoritesList extending GalleryList which extends ListFragment: public static class FavoritesList
I'm developing a ListView in an Android Fragment. The class extends ListFragment. I tried
I am using Actionbarsherlock and have a ListFragment and a DialogFragment within my Fragment
I have an android application (running under support library) which have MyListFragment class extends
How to update ListFragment whenever data updated in Sqlite Database.My following Fragment code works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.