Android Apps GridView的图片加文字效果

gridview_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:gravity="center">
    <LinearLayout android:layout_width="127dp"
  android:layout_height="96dp" android:gravity="center_vertical|center" android:background="@drawable/red_border">
   <ImageView
android:id="@+id/grid_image"
android:layout_width="125dp" 
android:layout_height="94dp"/>
  </LinearLayout>
<TextView android:layout_width="127dp" android:id="@+id/grid_time" style="@style/font12"
android:layout_height="wrap_content" android:gravity="center"/>
</LinearLayout>
private class ImageTextAdapter extends BaseAdapter{

private Context mContext;

public ImageTextAdapter(Context context){
mContext = context;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return imgPath.length;
}

@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}

@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = View.inflate(LocationRecordActivity.this, R.layout.gridview_list, null);
ImageView image = (ImageView) view.findViewById(R.id.grid_image);
TextView time_tv = (TextView)view.findViewById(R.id.grid_time);
image.setImageDrawable(drawable[position]);
time_tv.setText(getResources().getString(R.string.timed));
return view;
}
}


发布了65 篇原创文章 · 获赞 12 · 访问量 20万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览