大家好,我想在android的Gallery 在图片下面显示图片名字,可以实现这个功能吗??

解决方案 »

  1.   

    那就自定义一个适配器,继承自BaseAdapter。每个Item就是一个ImageView和TextView。就可以了
      

  2.   

    2个int数组  一个放入图标一个放文字然后使用  SimpleAdapter 去实现
      

  3.   


    2楼说得对的,现在gallery单纯显示图片的已经不多了,网上有很多这种例子。
      

  4.   


    我在BaseAdapter  里加了一个TextView了  ,也显示了文字但是滑向后退的时候图片和名字对不上,我的BaseAdapter的代码是这样的public class ImageAdapter extends BaseAdapter {
    private Context mContext;
    private TextView tv;
    //  图片数组源
    private Integer[] imgs = {R.drawable.minda,R.drawable.xida,R.drawable.yike,
    R.drawable.shifan,R.drawable.gd,R.drawable.gl,R.drawable.sy};
    private String[] schoolName={"广西民族大学","广西大学",
    "广西医科大学","广西师范大学","桂林电子科技大学","桂林理工大学","广西师范学院",}; public ImageAdapter(Context mContext,TextView tv){
    this.mContext=mContext;
    this.tv=tv;
    }
    public int getCount() {
    // TODO Auto-generated method stub
    return Integer.MAX_VALUE;
    } public Object getItem(int position) {
    // TODO Auto-generated method stub

    return position;
    } public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
    }
    public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    ImageView imageView=new ImageView(mContext);
    imageView.setScrollbarFadingEnabled(true);
    if(position==0 || position==1){
    tv.setText(schoolName[position%imgs.length]);
    }else{
    tv.setText(schoolName[(position-1)%imgs.length]);
    }
    imageView.setLayoutParams(new Gallery.LayoutParams(280,180));
    imageView.setImageResource(imgs[position%imgs.length]);
    return imageView;
    }}
      

  5.   

    直接用TextView 就好了啊
    final TextView textView = (TextView) convertView;
    textView.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null,
    null);
    textView.setText();
      

  6.   

    可以参考这个。http://blog.csdn.net/xwl617756974/article/details/6222085