Resimlerin ve onay kutularının bulunduğu bir ızgara görüntüm var ayrıca seçili görüntüleri silmek için 1 düğüme sahibim. Ama olayları nasıl yakalayabileceğimi anlayamıyorum. Satırlardaki düğmeler için birçok örnek gördüm, ancak listenin veya kılavuzun dışında bulunamıyor. Bir İmleç Adaptörü ve ListView ile, ne yaptık xml onClick yöntemi ayarlamak için olsaAdaptördeki tıklatma olayı nasıl yapılır
Benim Düzen
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<GridView
android:id="@+id/ImgGrid"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="0.97"
android:columnWidth="90sp"
android:gravity="center"
android:horizontalSpacing="10sp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10sp" />
<RelativeLayout
android:id="@+id/rlBookmark"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:layout_gravity="bottom" >
<Button
android:id="@+id/btnResGridSil"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Sil"
android:textColor="#FF0011"
android:textSize="15sp"
android:textStyle="normal" />
</RelativeLayout>
</LinearLayout>
Ve işte benim adaptör
public class ImageAdapter extends BaseAdapter {
Button btnsil;
private LayoutInflater mInflater;
private ArrayList<ResimBean> mRbList ;
Context context;
private ArrayList<Integer> selectedPic = new ArrayList<Integer>();
public ImageAdapter(Context ctx, ArrayList<ResimBean> rbList, Activity activity) {
try {
mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mRbList = rbList;
this.context = ctx;
} catch (Exception ex) {
String can = ex.getMessage();
}
}
public int getCount() {
return mRbList.size();
}
public ResimBean getItem(int position) {
return mRbList.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View convertView, final ViewGroup parent) {
ViewHolder holder;
try {
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.resgrid_item, null);
holder.imageview = (ImageView) convertView.findViewById(R.id.thumbImage);
holder.checkbox = (CheckBox) convertView.findViewById(R.id.itemCheckBox);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
String path = mRbList.get(position).getResimPath();
Uri uri = Uri.parse(path);
Bitmap res = Global.decodeUri(uri, parent.getContext());
holder.imageview.setImageBitmap(res);
holder.imageview.setRotation(90);
final int pos = position;
holder.checkbox.setTag(position);
holder.checkbox.setChecked(selectedPic.contains(mRbList.get(position)));
holder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int pos = (Integer) buttonView.getTag();
if (!buttonView.isChecked()) {
selectedPic.remove(pos);
} else if (buttonView.isChecked()) {
if (!selectedPic.contains(pos)) {
selectedPic.add(pos);
}
}
}
});
holder.imageview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent intent = new Intent(parent.getContext(), ResimDetayActivity.class);
intent.putExtra("reslist", mRbList);
intent.putExtra("position",position);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception ex) {
}
}
});
} catch (Exception ex) {
String err = ex.getMessage();
}
return convertView;
}
public ArrayList<Integer> getSelectedChecckedImages() {
return selectedPic;
}
public void clearSelectedCheckedImages() {
selectedPic.clear();
}
}
class ViewHolder {
ImageView imageview;
CheckBox checkbox;
int id;
}
Ben deneyeceğim @MikeT ty –