English 中文(简体)
如何从基地Adapter清单调查中挑选所有检查箱
原标题:How to select all/Unselect all check boxes from Listview in BaseAdapter

我想选择所有检查箱。

这里是我的法典。

private class BaseAdpterSendToServer extends BaseAdapter{

        String latti,calulationVal;
        String longi;
        String name;


        public BaseAdpterSendToServer(Context context) {
        layoutInflater = LayoutInflater.from(context);
        }

        @Override
        public int getCount() {

            return AndroidCamera.imagelistcount;
        }

        @Override
        public Object getItem(int arg0) {
            return arg0;
        }

        @Override
        public long getItemId(int arg0) {
            return arg0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup arg2) {

            viewHolder holder;

            if(convertView==null){
                holder  = new viewHolder();
                convertView =layoutInflater.inflate(R.layout.row_send_to_server, null);

                holder.showImage = (ImageView)convertView.findViewById(R.id.imgView);               
                holder.txtCalulation = (TextView)convertView.findViewById(R.id.txtCalualtionVal);
                holder.txtLatti = (TextView)convertView.findViewById(R.id.txtValLat);
                holder.txtLongi = (TextView)convertView.findViewById(R.id.txtValLong);
                holder.txtName = (TextView)convertView.findViewById(R.id.txtValName);
                holder.checkBox = (CheckBox)convertView.findViewById(R.id.chkBox);
                convertView.setTag(holder);
            }
            else{
                holder =(viewHolder)convertView.getTag();
            }
            int pos = 0;
            DBConnect d1 = new DBConnect(getApplicationContext(),"colorCode.db");

            pos = position+1;
            Cursor c = d1.selectedImageId(pos);


            String path = c.getString(1);
             calulationVal = c.getString(2);
             String s= calulationVal.toString();
             latti = c.getString(3);
             longi = c.getString(4);
             name = c.getString(5);
                d1.close();

          Bitmap b1 = BitmapFactory.decodeFile(path);


            System.out.println("THE BITMAP ISK ----- "+b1);

            holder.showImage.setImageBitmap(b1);
            holder.txtCalulation.setText(""+s);
            holder.txtLatti.setText(""+latti);
            holder.txtLongi.setText(""+longi);
            holder.txtName.setText(""+name);

            bt_f_unsel.setOnClickListener(new OnClickListener() {


                }
            });

            return convertView;
        }

        class viewHolder{
            TextView txtCalulation ,txtLatti, txtLongi,txtName;
            ImageView showImage;
            CheckBox checkBox;
        }

对我来说,任何帮助都是好的。

问题回答

You can make a button, which will go through your model (the data you have) and set false/true. Then you should call notifyDataSetChanged() to tell view to update the screen





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签