我在 gridview 的每个单元格中有 2 个图像。第一个图像是不可见的,第二个图像是可见的。我想要的是当我使用长按任何网格视图项目时,不可见的图像应该是可见的。谢谢。
myGrid.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
DELETE_SIT=1;
//Toast.makeText(FavorilerAct.this,"long click"+DELETE_SIT, Toast.LENGTH_SHORT).show();
((BaseAdapter)myGrid.getAdapter()).notifyDataSetChanged();
return true;
}
});
// 这是我在自定义适配器扩展 BaseAdapter 中的 getview 方法
public View getView(int position, View convertView, ViewGroup parent)
{
View MyView = convertView;
String url = stock_list.get(position);
if ( convertView == null )
{
LayoutInflater li = getLayoutInflater();
MyView = li.inflate(R.layout.gridview, null);
// Add The Text!!!
TextView tv = (TextView)MyView.findViewById(R.id.favorite_author);
tv.setText(names.get(position));
ImageView img=(ImageView)MyView.findViewById(R.id.favorite_image);
ImageView artiImg=(ImageView)MyView.findViewById(R.id.delete_fav_btn);
if(DELETE_SIT!=1)
artiImg.setVisibility(View.INVISIBLE);
else
artiImg.setVisibility(View.VISIBLE);
try {
img.setImageBitmap(loadBitmap(url));
} catch (IOException e) {
e.printStackTrace();
}
if(DELETE_SIT==1){
//ImageView delete_btn=(ImageView)MyView.findViewById(R.id.delete_fav_btn);
//artiImg.setImageResource(R.drawable.kapat);
artiImg.setVisibility(View.VISIBLE);
}
}
return MyView;
}