【发布时间】:2016-12-21 16:07:11
【问题描述】:
我正在 android 中制作图片库。我使用了可以在gridview中显示图像的gridview。但是,我无法显示带有标题日期的图像。然后,根据日期显示图像。我试图用文本视图在布局中显示图像。但是,它不起作用。请任何人都可以帮助我。如何显示如下图所示的图像。
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
String appName;
String name = null;
//LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = convertView;
Holder holder = null;
if (row == null) {
//convertView.getRecycledViewPool().setMaxRecycledViews(VIEW_TYPE,0);
//gridView = new View(context);
// get layout from mobile.xml
row = mInflater.inflate(R.layout.appsgridview, null);
holder = new Holder();
holder.appIcon = (ImageView)row.findViewById(R.id.imageView);
holder.ckbox =(CheckBox)row.findViewById(R.id.checkBox);
holder.textView=(TextView)row.findViewById(R.id.text);
row.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
holder.ckbox.setOnCheckedChangeListener(null);
}
holder.ckbox.setFocusable(false);
PackageInfo packInfo = packList.get(position);
ApplicationInfo packinfo=packages.get(position);
String namep=packinfo.name;
appName = packInfo.applicationInfo.loadLabel(context.getPackageManager()).toString();
holder.textView.setText(appName);
holder.appIcon.setImageDrawable(packInfo.applicationInfo.loadIcon(context.getPackageManager()));
holder.ckbox.setChecked(positionArray.get(position));
return row;
}
【问题讨论】:
-
您需要使用带有标题布局的回收站视图来进行此操作。