jeudi 24 septembre 2015

checkbos is display after delete image file in gridview layout

we have to delete multiple image in a gridview.checked multiple image and delete checked image.image is delete properly but checkbox was not remove checkbox is display.... Thanks in advanced. enter image description here

Adapter class:

holder.chb.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                // TODO Auto-generated method stub
                if(!holder.chb.isChecked()) {

                    if (!GridImageActivity.selectedFile.contains((String) list.get(position))) {
                        GridImageActivity.selectedFile.add((String) list.get(position));
                    // you use the ID field to hold the position

                    }} else {
                        GridImageActivity.selectedFile.remove((String) list .get(position));


                    }
            }
        });

Activity Calss:

delmemory.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                Iterator iterator = selectedFile.iterator();
                //Log.i("1", "" + iterator.next());
                while (iterator.hasNext()) {
                    new File(iterator.next().toString()).getAbsoluteFile().delete();

                    gridview.setAdapter(new ImageAdapter(GridImageActivity.this, DashboardActivity.imagelist,str));

                }
            }
        });

Gridview row xml layout file:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="match_parent"    
    android:layout_height="match_parent" >


    <com.JBSEventMemory.SquareImageView
        android:id="@+id/imagelayout_picture"
        android:layout_width="match_parent"
        android:layout_height="match_parent"       
        android:adjustViewBounds="true"
        android:scaleType="centerCrop" />

    <View
        android:id="@+id/imageCheckBorder"
        android:layout_width="180dp"
        android:layout_height="175dp"       
        android:visibility="gone" />

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"       
        android:layout_gravity="bottom"/>


</FrameLayout>

Gridview layout file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="5"    
    android:orientation="vertical" >
  <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:gravity="center"
        android:textSize="20dp"
        android:textStyle="bold"
        android:text="@string/titleMemory" />

    <TextView
        android:id="@+id/foldername"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.1"        
        android:textStyle="bold"
        android:layout_gravity="center_horizontal"        
        android:textSize="12sp"
        android:textColor="#000000"
        android:text="TextView" />

     <GridView
        android:id="@+id/gridview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:horizontalSpacing="10dp"
        android:numColumns="2"             
        android:layout_weight="4.5"      
        android:listSelector="#00000000"
        android:stretchMode="columnWidth"                
        android:layout_margin="3dp"                  
        android:verticalSpacing="10dp" />

      <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"                
        android:orientation="horizontal"
        android:weightSum="2" >

        <Button
            android:id="@+id/capture__btn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center"
            android:layout_marginBottom="4dp"         
            android:text="Capture " />
        <Button
            android:id="@+id/delete__btn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center"
            android:layout_marginBottom="4dp"         
            android:text="Delete " />
    </LinearLayout>

</LinearLayout>




Aucun commentaire:

Enregistrer un commentaire