Asynctask跳过for循环的一些值

时间:2013-03-06 05:51:59

标签: android

我必须逐个点击所选复选框的web服务,所以我正在使用for循环。但有时会调用webservice以获取已检查值的总数,但有时会跳过执行最后1,2或3的复选框,这些复选框由用户检查。我们可以做些什么来解决这个问题?请看一下代码。

for (int i = 0; i < count; i++) {
                    f = (FollowTypeData) mLvfollow.getAdapter().getItem(i);
                    if (f.isIschecked()) {
                        s = true;
                    }
                }

for (int ind = 0; ind < count; ind++) {

                        if (check) {
                            Log.e("checked value", ""+check);
                        } else {
                            f = (FollowTypeData) mLvfollow.getAdapter().getItem(ind);
                            if (f.isIschecked()) {
                                String values[] = { f.getId(), f.getType(),
                                        f.getIsfollowed() };
                                try {
                                    new FollowDeals().execute(values).get();
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                } catch (ExecutionException e) {
                                    e.printStackTrace();
                                }
                                m_id.add("" + f);
                            }
                        }

                    }

的AsyncTask

public class FollowDeals extends AsyncTask<String, Void, String> {
        @Override
        protected String doInBackground(String... params) {

            String followdata = "";
            String result = "";
            result = followdealData(params[0], params[1], params[2]);

            return followdata;
        }
}

0 个答案:

没有答案