Android Listview覆盖数据而不是追加

Android Listview覆盖数据而不是追加,android,listview,Android,Listview,在我的Android应用程序中,我正在使用带有索引值的Web服务 https://mysampleurl.com/sampledata?username=&&password=&&startindex=1&&endindex=10 并通过arraylist将提取的数据传递给BaseAdapter,并在listview中显示结果 当listview到达底部时,我将使用asynctask增加例如的索引值 https://mysampleurl.com/sampledata?username=&&p

在我的Android应用程序中,我正在使用带有索引值的Web服务

https://mysampleurl.com/sampledata?username=&&password=&&startindex=1&&endindex=10

并通过arraylist将提取的数据传递给BaseAdapter,并在listview中显示结果

当listview到达底部时,我将使用asynctask增加例如的索引值

https://mysampleurl.com/sampledata?username=&&password=&&startindex=11&&endindex=20.

我将接收数据并将其存储在arraylist中,然后继续

但当我将数组列表值传递给适配器时,它会覆盖现有数据,而不是附加以前的值

    @Override
public View getView(final int position, View convertView, ViewGroup parent) 
{
    System.out.println("position:"+position);
}
我已经在其他一些例子中检查了上面的代码,首先它给出了像1,2,…10这样的值。第二次它给出1,2,3,…20。但在我的应用程序中,它总是返回高达1,2,3…10的值

谁能告诉我我犯了什么错误

public ContentListAdapter (Context context, ArrayList<CommonData> contentList) 
{
    ctxt = context;
    this.ContentList = contentList;
    contentListRowInflater = LayoutInflater.from(context);
    mSelectedItemsIds=new SparseBooleanArray();
    checkBoxState=new boolean[contentList.size()];
}

    @Override
    public int getCount() {
        return (filteredContentList == null)?0:filteredContentList.size();
    }

    @Override
    public Object getItem(int position) {
        return filteredContentList.get(position);
    }

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

    Here only i pass the values and check the position

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) 
    {
        ContentListActivity.adapterFlag = false;
        DocumentListViewHolder viewHolder = null;
         if (convertView == null || convertView.getTag() == null) {
            convertView = contentListRowInflater.inflate(
                    R.layout.content_list_row, null);
              viewHolder = new DocumentListViewHolder();
            viewHolder.ivDocumentdoctypeIcon = (ImageView) convertView.findViewById(R.id.ivDocumentTypeIcon);
            viewHolder.tvDocumentTitle = (TextView) convertView.findViewById(R.id.tvDocumentTitle);
            viewHolder.tvsubitemcount = (TextView) convertView.findViewById(R.id.tvsubitemcount);
            viewHolder.ivarrowlauncher = (ImageView)convertView.findViewById(R.id.arrowlauncher);

            viewHolder.checkboxselection=(CheckBox)convertView.findViewById(R.id.checkboxdeletion);
            checkBoxSelection=viewHolder.checkboxselection;
             viewHolder.checkboxselection.setChecked(checkBoxState[position]);
            viewHolder.ivarrowlauncher = (ImageView)convertView.findViewById(R.id.arrowlauncher);
             mainlayoutrl = (RelativeLayout)convertView.findViewById(R.id.clrrlmain);
             sublayoutll = (LinearLayout)convertView.findViewById(R.id.clrowll);
             arrowlayoutll = (LinearLayout)convertView.findViewById(R.id.clarrowll);    
             final Context context = ContentListActivity.contentListActivity;
             if(viewHolder.checkboxselection.isChecked()) {
                                  mainlayoutrl.setBackgroundColor(ctxt.getResources().getColor(R.color.checkboxrowselect));
                  sublayoutll.setBackgroundColor(ctxt.getResources().getColor(R.color.checkboxrowselect));
                  arrowlayoutll.setBackgroundColor(ctxt.getResources().getColor(R.color.checkboxrowselect));
             } else  {
                  mainlayoutrl.setBackgroundColor(ctxt.getResources().getColor(R.color.white));
                  sublayoutll.setBackgroundColor(ctxt.getResources().getColor(R.color.white));
                  arrowlayoutll.setBackgroundColor(ctxt.getResources().getColor(R.color.white));
             }

             sublayoutll.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
            if (Config.networkConnectionCheck(context)) {
        if(filteredContentList.get(position).type.equalsIgnoreCase("FOLDER")) {
        ContentListActivity.ListarrowClick(position+1,context);
                        } else if (refreshFlag == false) {
        ContentListActivity.oldviewContent(position+1,context);
                        } else

                    } else {
                        ContentListActivity.oldofflineViewContent(position+1,context);
                    }
                }
             });

             arrowlayoutll.setOnClickListener(new OnClickListener() 
             {
                    @Override
                    public void onClick(View v) {
                    ContentListActivity.ListarrowClick(position+1,context);
                }
                 });
             viewHolder.ivfilesDownload=(ImageView)convertView.findViewById(R.id.document_list_row_download_imageview);

             //newly added by venkat 
             viewHolder.ivfilesdownloaded=(ImageView)convertView.findViewById(R.id.document_list_row_downloaded_imageview);

             viewHolder.tvDocumentDescription=(TextView)convertView.findViewById(R.id.tvdocumentdescription);
        } else {
            viewHolder = (DocumentListViewHolder) convertView.getTag();
        }
        viewHolder.tvDocumentTitle.setText(filteredContentList.get(position).name);
            String desc = filteredContentList.get(position).versiondescription;
        if (desc != null) {
            viewHolder.tvDocumentDescription.setText(filteredContentList
                    .get(position).versiondescription);
        }
        String doctype = filteredContentList.get(position).type;
        String subitemcount = filteredContentList.get(position).subitemcount;
        if (doctype.equalsIgnoreCase(ctxt.getResources()
                .getString(R.string.pdf))) {
            viewHolder.ivDocumentdoctypeIcon
                    .setImageResource(R.drawable.pdfbigicon);
        } else if (doctype.equalsIgnoreCase(ctxt.getResources().getString(
                R.string.swf))) {
            viewHolder.ivDocumentdoctypeIcon
                    .setImageResource(R.drawable.flashbigicon);
        } if(doctype.equalsIgnoreCase(ctxt.getResources().getString(
                R.string.folder)))
        {
            viewHolder.ivarrowlauncher.setVisibility(View.INVISIBLE);
        }
        if (filteredContentList.get(position).isupdateavailable
                .equalsIgnoreCase(ctxt.getResources().getString(
                        R.string.update_false_status))) {
        } else if (filteredContentList.get(position).isupdateavailable
                .equalsIgnoreCase(ctxt.getResources().getString(
                        R.string.update_true_status))) {
                    WebAPI webapi = new WebAPI(ctxt);
                            if (LoginHandler.arraylistdata.size() == 1) {
                                user_id = LoginHandler.arraylistdata.get(0)
                                        .getUserid();
                                org_id = LoginHandler.arraylistdata.get(0)
                                        .getOrgId();
                            } else {
                                user_id = LoginHandler.arraylistdata.get(
                                        OrgListActivity.selected_org_pos)
                                        .getUserid();
                                org_id = LoginHandler.arraylistdata.get(
                                        OrgListActivity.selected_org_pos)
                                        .getOrgId();
                            }
                            LoginDatabaseHandler loginDBHandler = new LoginDatabaseHandler(
                                    ctxt);
                            loginDBHandler.open();
                            int toglState = loginDBHandler.checkOffToggleState(
                                    user_id, org_id, filteredContentList
                                            .get(position).dockey.toString());              
                                }
                            } else
                                versionUpdate(position, ctxt);
                        }
                    });
        }
        /*ends*/        
        return convertView;
    }

显示适配器的代码..如果收到数据,则应将其添加到现有的arraylist..在调用adapter.notifydatasetchanged之后。我已添加适配器@KanakSony代码的一些重要部分。请看一看