0

In my program i have to Sync all the List Items by doing click on Sync button, but whenever i do tap on Sync button, it is syncing only first item of the List and whereas, i have to Sync all the List Item(s) available in a List.

int position;

 ImageButton buttonSync = (ImageButton) findViewById(R.id.sync_btn);
    buttonSync.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            startUpload(position);
        }
    });

public void startUpload(final int position) {      

    Runnable runnable = new Runnable() {

    public void run() {

     handler.post(new Runnable() {
    public void run() {

    View v = lstView.getChildAt(position - lstView.getFirstVisiblePosition());

    // Show ProgressBar
    ProgressBar progress = (ProgressBar)v.findViewById(R.id.progressBar);
    progress.setVisibility(View.VISIBLE);

    // Status
    ImageView status = (ImageView)v.findViewById(R.id.ColStatus);
    status.setImageResource(R.drawable.bullet_button);

    new UploadFileAsync().execute(String.valueOf(position));   
    }
    });

    }
    };
    new Thread(runnable).start();
    }
Sun
  • 6,768
  • 25
  • 76
  • 131

1 Answers1

1
ImageButton buttonSync = (ImageButton) findViewById(R.id.sync_btn);
    buttonSync.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            for(int i=9;i<listview.getchildCount();i++)
             {
            startUpload(i);
            }
        }
    });

please use this code and remove listview code from your startUpload() . i hope that its useful to you..

dipali
  • 10,966
  • 5
  • 25
  • 51
  • hello, facing issue in existing code, see this:http://stackoverflow.com/questions/21495199/how-to-sync-whole-list-instead-of-only-visible-records – Sun Feb 01 '14 at 07:29