Skip to content Skip to sidebar Skip to footer

How To Display The Image With Name In Android

Hi In My application I am displaying images by using swipe.Now, i want to display the under the image i want to display the name. I want to write the some name in that image.how to

Solution 1:

    description_images = getIntent().getExtras().getStringArray("images_name"); //ARRAY OF ALL TEXT ASSOCIATED TO IMAGES
    mImages = getIntent().getExtras().getStringArray("images_path"); //ARRAY OF ALL IMAGE PATHS

private class ImagePagerAdapter extends PagerAdapter {
        @Override
        public int getCount() {
            return mImages.length;
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public View instantiateItem(ViewGroup container, int position) {
            LayoutInflater inflater = LayoutInflater.from(container.getContext());
            View view = inflater.inflate(R.layout.image_view, null);
            final ImageView imageView = (ImageView)view.findViewById(R.id.iv_image);
            final TextView textView = (TextView )view.findViewById(R.id.iv_text);

            textView.setText(description_images[position]);
            imageLoader.displayImage(mImages[position], imageView, options);
            container.addView(view, 0);
            return view;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }
    }

Corresponding XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/iv_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:id="@+id/iv_text"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true" />

</RelativeLayout>

Post a Comment for "How To Display The Image With Name In Android"