There is a gallery.

public class ImageGridFragment2 extends Fragment { protected AbsListView listView; public static final int INDEX = 1; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fr_image_grid2, container, false); listView = (GridView) rootView.findViewById(R.id.grid); ((GridView) listView).setAdapter(new ImageAdapter(getActivity())); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { startImagePagerActivity(position); } }); return rootView; } private void startImagePagerActivity(int position) { Intent intent = new Intent(getActivity(), SimpleImageActivity.class); intent.putExtra(Constants.Extra.FRAGMENT_INDEX, ImagePagerFragment.INDEX); intent.putExtra(Constants.Extra.IMAGE_POSITION, position); startActivity(intent); } private class ImageAdapter extends BaseAdapter { private String[] IMAGE_URLS = Constants.IMAGES; private LayoutInflater inflater; private DisplayImageOptions options; ImageAdapter(Context context) { inflater = LayoutInflater.from(context); options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_stub) .showImageForEmptyUri(R.drawable.ic_empty) .showImageOnFail(R.drawable.ic_error) .cacheInMemory(true) .cacheOnDisk(true) .considerExifParams(true) .bitmapConfig(Bitmap.Config.RGB_565) .build(); } @Override public int getCount() { return IMAGE_URLS.length; } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; View view = convertView; if (view == null) { view = inflater.inflate(R.layout.item_grid_image, parent, false); holder = new ViewHolder(); assert view != null; holder.text = (TextView) view.findViewById(R.id.text); holder.imageView = (ImageView) view.findViewById(R.id.image); holder.progressBar = (ProgressBar) view.findViewById(R.id.progress); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } holder.text.setText("Item " + (position + 1)); ImageLoader.getInstance() .displayImage(IMAGE_URLS[position], holder.imageView, options, new SimpleImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { holder.progressBar.setProgress(0); holder.progressBar.setVisibility(View.VISIBLE); } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { holder.progressBar.setVisibility(View.GONE); } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { holder.progressBar.setVisibility(View.GONE); } }, new ImageLoadingProgressListener() { @Override public void onProgressUpdate(String imageUri, View view, int current, int total) { holder.progressBar.setProgress(Math.round(100.0f * current / total)); } }); return view; } } static class ViewHolder { TextView text; ImageView imageView; ProgressBar progressBar; } } 

item_grid_image.xml

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="120dip"> <ImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="match_parent" android:adjustViewBounds="true" android:scaleType="centerCrop" /> <ProgressBar android:id="@+id/progress" android:layout_width="match_parent" android:layout_height="wrap_content" android:indeterminate="false" android:max="100" android:layout_gravity="bottom" /> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </FrameLayout> 

The result is a picture and the signature Item for it (some kind there). How can I print my own label for each photo instead of Item?

    2 answers 2

    I think the line

     holder.text.setText("Item " + (position + 1)); 

    It needs to be replaced by

     holder.text.setText("свой текст"); 
    • Oooh ... Gallery, it seems downloaded from the Internet (or worse) and such a question "Item (some kind there). How can I remove my inscription for each photo instead of Item?" and "holder.text.setText (" Item "+ (position + 1));" Oh .... - Denis Kotlyarov
    • Gallery from the example of Android Universal-Image-Loader. holder.text.setText ("your text"); displays the same text under all the pictures, and I need my own signature under each picture. - Skivs

    All figured out. It was easier than I thought. Added a list with captions. public String[] title = new String[] {"Подпись 1", "Подпись 2", "Подпись 3", ... и так далее} and made the conclusion holder.text.setText(title[position]);