开发者

How to create a Fragment loading information from SQLDatabase?

开发者 https://www.devze.com 2023-03-18 23:10 出处:网络
I am creating an activity that implements a fragment list and a regular fragment showing details of the list. i am having a VERY hard time trying to take the android developer tutorial on fragment cur

I am creating an activity that implements a fragment list and a regular fragment showing details of the list. i am having a VERY hard time trying to take the android developer tutorial on fragment cursor and use it.

I am trying to load the title's from my SQLdatabse into the fragment list. And when the item is clicked show details for it. I know i will just store the id of the item in a extra and pick it out in the details fragment to开发者_运维问答 get the information.

Im just kind of confused on the whole ListFragment class.

Here is my source code where im at so far...

public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FragmentManager fm = new getFragmentManager();
    if(fm.findFragmentById(android.R.id.content)== null){
        CursorLoaderListFragment list = new CursorLoaderListFragment();
        fm.beginTransaction().add(android.R.id.content, list).commit();

    }

}
public static class CursorLoaderListFragment extends ListFragment{

    SimpleCursorAdapter mAdapter;

    String mCurFilter;

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

            setEmptyText("No Task");
            setHasOptionsMenu(true);



        }
}

}

If someone has a better way than what im doing PLEASE let me know and provide an example.

Thanks!

0

精彩评论

暂无评论...
验证码 换一张
取 消