SlideShare a Scribd company logo
Now Loading. Please Wait ...




                  GTUG Android
        Android                  Android3.0



                                              Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Fragment fr = new MyFragment();
                 FragmentTransaction tr =
                      getSupportFragmentManager().beginTransaction();
                 tr.add(fr, "MyFragment");
                 tr.commit();




                                                           Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
public Fragment createFragment(int n){
                     MyFragment f = new MyFragment();
                     Bundle bundle = new Bundle();
                     bundle.putInt("num", n);
                     f.setArguments(bundle);
                     return f;
                 }

                 @Override
                 public void onCreate(Bundle savedInstanceState) {
                     super.onCreate(savedInstanceState);
                     if(savedInstanceState!=null){
                         n = savedInstanceState.getInt("num");
                     }
                     else{
                         Bundle bundle = getArguments();
                         if(bundle!=null){
                             n = bundle.getInt("num");
                         }
                     }
                 }

                                                                     Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Fragment fr = new MyFragment(n++);
                 FragmentTransaction tr =
                      getSupportFragmentManager().beginTransaction();
                 tr.replace(R.id.frameLayout1, fr);
                 tr.addToBackStack("task");
                 tr.commit();




                                                            Re:Kayo-System Co.,Ltd.

2011   10   22
Fragment f =
                    getSupportFragmentManager().
                       findFragmentByTag("tag");




                                Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
class MyAsyncTask extends AsyncTask<Void, Void, Void>{
                     Handler handler;
                     Context context;

                     @Override
                     protected Void doInBackground(Void... params) {
                         Cursor cur =
                             context.getContentResolver().query(
                                      Media.EXTERNAL_CONTENT_URI,
                                      null, null, null, null);
                         handler.sendMessage(handler.obtainMessage(0, cur));
                         return null;
                     }
                 }




                                                                  Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
LoaderCallbacks<T>


                 Bundle bundle = new Bundle();
                 getSupportLoaderManager().initLoader(
                      R.layout.main, bundle, this);




                                                         Re:Kayo-System Co.,Ltd.

2011   10   22
Bundle bundle = new Bundle();
                 getSupportLoaderManager().restartLoader(
                      R.layout.main, bundle, this);




                                                      Re:Kayo-System Co.,Ltd.

2011   10   22
@Override
                 public void onDestroy() {
                     super.onDestroy();
                     getLoaderManager().destroyLoader(R.layout.main);
                 }




                                                          Re:Kayo-System Co.,Ltd.

2011   10   22
LoaderCallbacks<T>
                 public static class MyLoaderFragment extends Fragment implements
                 LoaderCallbacks<Cursor>{
                     CursorAdapter adapter;

                     public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
                         return new CursorLoader(getActivity(),
                                 Media.EXTERNAL_CONTENT_URI,
                                 null, null, null, null);
                     }

                     public void onLoadFinished(Loader<Cursor> arg0, Cursor arg1) {
                         Cursor cur = adapter.swapCursor(arg1);
                     }

                     public void onLoaderReset(Loader<Cursor> arg0) {

                     }

                 }


                                                                            Re:Kayo-System Co.,Ltd.

2011   10   22
class ValueItem {
                     String name;
                     int age;
                 }




                                     Re:Kayo-System Co.,Ltd.

2011   10   22
public static class MyLoaderFragment2 extends Fragment implements
                 LoaderCallbacks<List<ValueItem>>{

                     public Loader<List<ValueItem>> onCreateLoader(int arg0, Bundle arg1) {
                         // TODO Auto-generated method stub
                         return null;
                     }

                     public void onLoadFinished(Loader<List<ValueItem>> arg0,
                             List<ValueItem> arg1) {
                         // TODO Auto-generated method stub

                     }

                     public void onLoaderReset(Loader<List<ValueItem>> arg0) {
                         // TODO Auto-generated method stub

                     }

                 }


                                                                                Re:Kayo-System Co.,Ltd.

2011   10   22
static class MyAsyncTaskLoader extends AsyncTaskLoader<List<ValueItem>>{

                       public MyAsyncTaskLoader(Context context) {
                           super(context);
                       }

                       @Override
                       public List<ValueItem> loadInBackground() {
                           List<ValueItem> list = new ArrayList<ValueItem>();
                           return list;
                       }
                 }




                     public Loader<List<ValueItem>> onCreateLoader(int arg0, Bundle arg1) {
                         MyAsyncTaskLoader l = new MyAsyncTaskLoader(getActivity());
                         l.forceLoad();
                         return l;
                     }

                                                                             Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
 <android.support.v4.view.ViewPager
                         android:layout_width="match_parent"
                         android:layout_height="match_parent"
                         … />




                                                       Re:Kayo-System Co.,Ltd.

2011   10   22
public         static class MyAdapter extends FragmentPagerAdapter {
                                 public MyAdapter(FragmentManager fm) {
                                     super(fm);
                                 }

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

                                 @Override
                                 public Fragment getItem(int position) {
                                     return ArrayListFragment.newInstance(position);
                                 }
                         }




                                                                                Re:Kayo-System Co.,Ltd.

2011   10   22
mViewPager.setAdapter(adapter);




                 mViewPager.setOnPageChangeListener(this);




                                                      Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22
Re:Kayo-System Co.,Ltd.

2011   10   22

More Related Content

京都Gtugコンパチapi