List of usage examples for android.widget GridView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:io.oceanos.shaderbox.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adapter = new ShaderItemAdapter(getBaseContext()); adapter.fetchData();/*from w w w .j av a 2 s . co m*/ GridView mGridView = (GridView) findViewById(R.id.list); mGridView.setAdapter(adapter); mGridView.setOnItemClickListener(this); }
From source file:de.j4velin.picturechooser.ImagesFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.gallery, null); 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.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()) { images.add(new GridItem(cur.getString(1), cur.getString(0))); cur.moveToNext();//from w w w. j av a2 s. c om } } 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) { ((Main) getActivity()).imageSelected(images.get(position).path); } }); return v; }
From source file:lib.picturechooser.ImagesFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.gallery, null); 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.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()) { images.add(new GridItem(cur.getString(1), cur.getString(0))); cur.moveToNext();//from www. j a v a2s . c om } } 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); } }); return v; }
From source file:org.bwgz.quotation.activity.QuotationPicksActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.standard_grid_view); setTitle(R.string.quotations_title); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); picksView = (PicksView) inflater.inflate(R.layout.quotation_picks_expanded_view, null); picksView.setActivityClass(QuotationActivity.class); picksView.setExpand(true);//from w w w. ja v a 2 s. com initLoader(this, PickQuotation.CONTENT_URI, QuotationQuery.PROJECTION, null, null, null); GridView gridView = (GridView) findViewById(R.id.grid_view); gridView.setAdapter(new ActivityAdapter(new View[] { picksView })); }
From source file:org.bwgz.quotation.activity.SubjectPicksActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.standard_grid_view); setTitle(R.string.subjects_title);/* w ww . j a va2s. c om*/ LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); picksView = (PicksView) inflater.inflate(R.layout.subject_picks_expanded_view, null); picksView.setActivityClass(SubjectActivity.class); picksView.setExpand(true); initLoader(this, PickSubject.CONTENT_URI, new String[] { Subject.FULL_ID, Subject.NAME, Subject.DESCRIPTION, Subject.IMAGE_ID, Subject.QUOTATION_COUNT, BookmarkSubject.BOOKMARK_ID }, null, null, null); GridView gridView = (GridView) findViewById(R.id.grid_view); gridView.setAdapter(new ActivityAdapter(new View[] { picksView })); }
From source file:com.im4j.picturebeautify.picchooser.ImagesFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.gallery, null); 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.BUCKET_ID + " = ?", new String[] { String.valueOf(getArguments().getInt("bucket")) }, MediaStore.Images.Media.DATE_MODIFIED + " ASC"); final List<GridItem> images = new ArrayList<GridItem>(cur.getCount()); if (cur != null) { if (cur.moveToFirst()) { while (!cur.isAfterLast()) { images.add(new GridItem(cur.getString(1), cur.getString(0), cur.getString(2), cur.getLong(3))); cur.moveToNext();//from ww w . ja va 2s. c o m } } 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); } }); return v; }
From source file:org.fossasia.phimpme.editor.picchooser.ImagesFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View v = inflater.inflate(R.layout.gallery, null); 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.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()) { images.add(new GridItem(cur.getString(1), cur.getString(0), cur.getString(2), cur.getLong(3))); cur.moveToNext();/*from w w w . java2 s .co m*/ } } 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); } }); return v; }
From source file:com.chatwing.whitelabel.fragments.EmoticonsFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mDelegate.inject(this); Serializable serializable = getArguments().getSerializable(EXTRA_EMOTICONS); Emoticon[] emoticons;/* w w w . j av a 2 s .c o m*/ if (serializable instanceof Emoticon[]) { emoticons = (Emoticon[]) serializable; } else { emoticons = JsonConstantsProvider.emoticonObject; //FIXME How can serializable be null? } adapter.setEmoticons(emoticons); GridView viewPager = (GridView) view.findViewById(R.id.gridview); viewPager.setAdapter(adapter); }
From source file:de.j4velin.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 ww . j av a2 s . c o 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(), 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) { ((Main) getActivity()).showBucket(((BucketItem) buckets.get(position)).id); } }); } return v; }
From source file:com.im4j.picturebeautify.picchooser.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;//from w ww .j a v a 2 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(), 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; }