我有一个用于gridview的自定义适配器。
public class PDFAdapter extends BaseAdapter {
...
public View getView(int position, View convertView, ViewGroup parent) {
int type = getItemViewType(position);
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater
.inflate(R.layout.custom_layout, null);
}
Button1 = (Button) convertView
.findViewById(R.id.button1);
Button2 = (Button) convertView
.findViewById(R.id.button2);
Button1 .setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Button2.setVisibility(View.INVISIBLE);
}
});
Button2 .setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Button1.setVisibility(View.INVISIBLE);
}
});
return convertView;
}
...
}
我的问题在这里,我无法从View.INVISIBLE的onClick方法访问UI。单击两个按钮后没有任何变化。我错过了什么?