我想要两件事:
在我隐藏PLAY按钮之前,将其他按钮保留在相同的位置
private int resourceId;
private List<Object> objArrayList;
public SparseBooleanArray mCheckedState;
public AddProductsAdapter(Context context, int resource, List<Object> objList ) {
super(context, resource,objList);
this.context = context;
this.resourceId = resource;
mCheckedState = new SparseBooleanArray(objList.size());
this.objArrayList = objList;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View productview = convertView;
ProductHolder productHolder;
if (productview == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
productview = inflater.inflate(resourceId, parent, false);
productHolder = new ProductHolder();
productHolder.productNameView = (TextView) productview.findViewById(R.id.nameProductView);
productHolder.productIdView = (TextView) productview.findViewById(R.id.IdProductView);
productHolder.productPriceView = (TextView) productview.findViewById(R.id.priceProductView);
productHolder.checkBox = (CheckBox) productview.findViewById(R.id.checkBoxView);
productview.setTag(productHolder);
productview.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ProductHolder productHolder = (ProductHolder) v.getTag();
if (productHolder.checkBox.isChecked()){
productHolder.checkBox.setChecked(false);
}
else{
productHolder.checkBox.setChecked(true);
}
}
});
}
else{
productHolder = (ProductHolder) productview.getTag();
}
try {
if(objArrayList!=null){
ProductEntity productEntity= (ProductEntity) objArrayList.get(position);
String productName = productEntity.getName();
String productId = productEntity.getProductId();
String productPriceStandrd = productEntity.getStandard();
productHolder.productNameView.setText(productName);
productHolder.productIdView.setText(productId);
productHolder.productPriceView.setText(productPriceStandrd);
//productHolder.checkBox.setTag(position);
productHolder.checkBox.setTag(position);
productHolder.checkBox.setChecked(mCheckedState.get(position, false));
productHolder.checkBox.setOnCheckedChangeListener(this);
}
}
catch (Exception e) {
e.printStackTrace();
}
return productview;
}
public boolean isChecked(int position) {
return mCheckedState.get(position, false);
}
public void setChecked(int position, boolean isChecked) {
mCheckedState.put(position, isChecked);
}
public void toggle(int position) {
setChecked(position, !isChecked(position));
}
@Override
public int getCount() {
return objArrayList != null ? objArrayList.size() : 0;
}
private class ProductHolder {
TextView productNameView;
TextView productIdView;
TextView productPriceView;
CheckBox checkBox;
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mCheckedState.put((Integer) buttonView.getTag(), isChecked);
}
`
答案 0 :(得分:1)
将动作侦听器添加到 PLAY 按钮b1
。
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
b1.setVisible(false);
}
}
它应该为你隐藏。