List of usage examples for android.widget GridView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:lib.picturechooser.BucketsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.gallery, null); String[] projection = new String[] { MediaStore.Images.Media.DATA, MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore.Images.Media.BUCKET_ID }; Cursor cur = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " ASC, " + MediaStore.Images.Media.DATE_MODIFIED + " DESC"); final List<GridItem> buckets = new ArrayList<GridItem>(); BucketItem lastBucket = null;/* w w w. ja va2 s .co m*/ if (cur != null) { if (cur.moveToFirst()) { while (!cur.isAfterLast()) { if (lastBucket == null || !lastBucket.name.equals(cur.getString(1))) { lastBucket = new BucketItem(cur.getString(1), cur.getString(0), cur.getInt(2)); buckets.add(lastBucket); } else { lastBucket.images++; } cur.moveToNext(); } } cur.close(); } if (buckets.isEmpty()) { Toast.makeText(getActivity(), "", Toast.LENGTH_SHORT).show(); getActivity().finish(); } else { GridView grid = (GridView) v.findViewById(R.id.grid); grid.setAdapter(new GalleryAdapter(getActivity(), buckets)); grid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((SelectPictureActivity) getActivity()).showBucket(((BucketItem) buckets.get(position)).id); } }); } return v; }
From source file:com.feigdev.fourcolumngv.FourColumnGridViewActivity.java
/** Called when the activity is first created. */ @Override/*w ww.ja v a 2s.c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); GridView g = (GridView) findViewById(R.id.myGrid); g.setAdapter(new ImageAdapter(this)); Display display = getWindowManager().getDefaultDisplay(); imgSize = new Point(); imgSize.set((display.getWidth()) / 4, (display.getWidth()) / 4); }
From source file:com.soundcloud.android.crop.support.ImagesFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.gallery, null); Toolbar toolbar = (Toolbar) v.findViewById(R.id.toolbar); toolbar.setTitle(""); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override/* w w w . j ava 2 s . com*/ public void onClick(View v) { getActivity().onBackPressed(); } }); Cursor cur = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] { MediaStore.Images.Media.DATA, MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.DATE_TAKEN, MediaStore.Images.Media.SIZE, MediaStore.Images.Media._ID }, MediaStore.Images.Media.BUCKET_ID + " = ?", new String[] { String.valueOf(getArguments().getInt("bucket")) }, MediaStore.Images.Media.DATE_MODIFIED + " DESC"); final List<GridItem> images = new ArrayList<GridItem>(cur.getCount()); if (cur != null) { if (cur.moveToFirst()) { while (!cur.isAfterLast()) { Uri uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "" + cur.getString(4)); images.add(new GridItem(cur.getString(1), cur.getString(0), cur.getString(2), cur.getLong(3), uri)); cur.moveToNext(); } } cur.close(); } GridView grid = (GridView) v.findViewById(R.id.grid); grid.setAdapter(new GalleryAdapter(getActivity(), images)); grid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((SelectPictureActivity) getActivity()).imageSelected(images.get(position).path, images.get(position).imageTaken, images.get(position).imageSize, images.get(position).uri); } }); return v; }
From source file:com.example.syb9111.myapplication.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setActionBarIcon(R.drawable.ic_ab_drawer); GridView gridView = (GridView) findViewById(R.id.gridView); gridView.setAdapter(new GridViewAdapter()); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override// w w w .ja v a2 s . co m public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String url = (String) view.getTag(); DetailActivity.launch(HomeActivity.this, view.findViewById(R.id.image), url); } }); drawer = (DrawerLayout) findViewById(R.id.drawer); drawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); }
From source file:com.antonioleiva.materialeverywhere.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setActionBarIcon(R.drawable.ic_ab_drawer); GridView gridView = (GridView) findViewById(R.id.gridView); gridView.setAdapter(new GridViewAdapter()); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w . j a va 2 s.c om public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String url = (String) view.getTag(); DetailActivity.launch(HomeActivity.this, view.findViewById(R.id.image), url); } }); drawer = (DrawerLayout) findViewById(R.id.drawer); drawer.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); }
From source file:com.infamous.cm.icons.fragment.IconFragmentAll.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.all_icons_main, container, false); int iconSize = getResources().getDimensionPixelSize(R.dimen.allapps_icon_preview); GridView gridview = (GridView) view.findViewById(R.id.icon_grid); gridview.setAdapter(new IconAdapter(getActivity(), iconSize)); CONTENT_URI = Uri.parse("content://" + IconsProvider.class.getCanonicalName()); return view;/* w w w .ja v a 2s .co m*/ }
From source file:com.RecEx.dtuexamtools.Groups.java
/** Called when the activity is first created. */ @Override/*w ww . java 2 s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mGaInstance = GoogleAnalytics.getInstance(this); mGaTracker = mGaInstance.getTracker("UA-40877184-1"); // Placeholder tracking ID. createButton("Group A"); createButton("Group B"); GridView gridView = (GridView) findViewById(R.id.gridview); gridView.setAdapter(new CustomAdapter(mButtons)); }
From source file:com.soundcloud.android.crop.support.BucketsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.gallery, null); Toolbar toolbar = (Toolbar) v.findViewById(R.id.toolbar); toolbar.setTitle(""); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override/*from w w w.java 2s . c om*/ public void onClick(View v) { getActivity().onBackPressed(); } }); String[] projection = new String[] { MediaStore.Images.Media.DATA, MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore.Images.Media.BUCKET_ID }; Cursor cur = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " ASC, " + MediaStore.Images.Media.DATE_MODIFIED + " DESC"); final List<GridItem> buckets = new ArrayList<GridItem>(); BucketItem lastBucket = null; if (cur != null) { if (cur.moveToFirst()) { while (!cur.isAfterLast()) { if (lastBucket == null || !lastBucket.name.equals(cur.getString(1))) { lastBucket = new BucketItem(cur.getString(1), cur.getString(0), "", cur.getInt(2)); buckets.add(lastBucket); } else { lastBucket.images++; } cur.moveToNext(); } } cur.close(); } if (buckets.isEmpty()) { Toast.makeText(getActivity(), R.string.no_images, Toast.LENGTH_SHORT).show(); getActivity().finish(); } else { GridView grid = (GridView) v.findViewById(R.id.grid); grid.setAdapter(new GalleryAdapter(getActivity(), buckets)); grid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((SelectPictureActivity) getActivity()).showBucket(((BucketItem) buckets.get(position)).id); } }); } return v; }
From source file:com.gscoder.android.labadienatts.Manager.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.liepamanager); GridView gridview = (GridView) findViewById(R.id.dashboard_grid); gridview.setAdapter(new ImageAdapter(this)); gridview.setOnItemClickListener(this); // Hack to disable GridView scrolling gridview.setOnTouchListener(new GridView.OnTouchListener() { @Override/* w ww.j a va 2 s . c o m*/ public boolean onTouch(View v, MotionEvent event) { return event.getAction() == MotionEvent.ACTION_MOVE; } }); ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0); }
From source file:com.intel.demo.fragmenttransition.FragmentTransitionFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { GridView grid = (GridView) view.findViewById(R.id.grid); //grid.setAdapter(mChartAdapter); grid.setAdapter(mAdapter); //grid.setOnItemClickListener(this); }