Android 中断任务结果<;ArrayList<;HashMap<;字符串,字符串>&燃气轮机&燃气轮机;进入另一个列表

Android 中断任务结果<;ArrayList<;HashMap<;字符串,字符串>&燃气轮机&燃气轮机;进入另一个列表,android,Android,有没有办法中断AsyncTaskResult>> 列入名单? 或者得到30,40,。。只是它的价值 我有一个异步类,它将webservice获取的结果返回给适配器。 现在由于数据量巨大,我想通过传递将结果分割成单独的部分 异步类的结果数 下面是myasync类: protected AsyncTaskResult<ArrayList<HashMap<String, String>>> doInBackground( String... arg0

有没有办法中断AsyncTaskResult>> 列入名单? 或者得到30,40,。。只是它的价值

我有一个异步类,它将webservice获取的结果返回给适配器。 现在由于数据量巨大,我想通过传递将结果分割成单独的部分 异步类的结果数

下面是myasync类:

protected AsyncTaskResult<ArrayList<HashMap<String, String>>> doInBackground(
        String... arg0) {

        String xml = "Get String from my web service class"
        myXmlParsingClass myparser = new myXmlParsingClass (xml, "getitem");
        myparser .runParser();

        AsyncTaskResult<ArrayList<HashMap<String, String>>> myresult = new AsyncTaskResult<ArrayList<HashMap<String, String>>>(myXmlParsingClass .getParsedData());

        return myresult ;

    }
在MyAsyncClass中:

public MyAsyncClass ( View context,String _id) {
    this.targetCtx = context ;
    id = _id;
}

public MyAsyncClass ( View context,String _id,int _ID_To_Show) {
    this.targetCtx = context ;
    id = _id;
    ID_To_Show= _ID_To_Show;
}
在执行后方法上:

if(ID_To_Show >0 ){
     MySecondAdapter Madapter = new MySecondAdapter(targetCtx,        myresult.getResult(),ID_To_Show);
     mylist.setAdapter(Madapter);
   }else{
   MySecondAdapter Madapter = new MySecondAdapter(targetCtx, myresult.getResult());
   mylist.setAdapter(Madapter);
最后,在MySecondAdapter中,我添加了以下内容:

public MySecondAdapter(View a, ArrayList<HashMap<String, String>> id,int _ID_To_Show) {
    idfromhayoolafetch = id;
    myinflater = (LayoutInflater) AppContext.getAppContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ID_To_Show= _ID_To_Show;
}
public MySecondAdapter(View a, ArrayList<HashMap<String, String>> id) {
    idfromhayoolafetch = id;
    myinflater = (LayoutInflater) AppContext.getAppContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
    if(ID_To_Show>0){
        return ID_To_Show;  
    }else{
    return idfromhayoolafetch.size();
    }
    }
public MySecondAdapter(视图a、ArrayList id、int\u id\u To\u Show){
idfromhayoolafetch=id;
myinflater=(LayoutFlater)AppContext.getAppContext().getSystemService(Context.LAYOUT\u INFLATER\u SERVICE);
ID_To_Show=_ID_To_Show;
}
public MySecondAdapter(视图a,ArrayList id){
idfromhayoolafetch=id;
myinflater=(LayoutFlater)AppContext.getAppContext().getSystemService(Context.LAYOUT\u INFLATER\u SERVICE);
}
public int getCount(){
如果(ID到显示>0){
将ID_返回到_Show;
}否则{
返回idfromhayoolafetch.size();
}
}
这种方法显示我希望在每次调用中显示的项目数量,并且我可以将值传递给它 但我还有别的办法吗?
问题是我不能要求hayoola限制响应中的值。

这样的请求应该由服务器it自行处理。 和中一样,服务器应该接受要返回的项目数,并且只发送那个么多的项目

但如果您仍希望异步任务处理它,则可以执行以下操作:

protected AsyncTaskResult<ArrayList<HashMap<String, String>>> doInBackground(
        String... arg0) {

        String xml = "Get String from my web service class"
        myXmlParsingClass myparser = new myXmlParsingClass (xml, "getitem");
        myparser .runParser();

        AsyncTaskResult<ArrayList<HashMap<String, String>>> myresult = new AsyncTaskResult<ArrayList<HashMap<String, String>>>(myXmlParsingClass .getParsedData());
        ArrayList<HashMap<String, String>> result=myresult.getResult();
        myresult.setResult(result.subList(0,maxItems));//maxItems=30 set it while creating async task object
        return myresult ;

    }
受保护的AsyncTaskResult doInBackground(
字符串…arg0){
String xml=“从我的web服务类获取字符串”
myXmlParsingClass myparser=新的myXmlParsingClass(xml,“getitem”);
myparser.runParser();
AsyncTaskResult myresult=新的AsyncTaskResult(myXmlParsingClass.getParsedData());
ArrayList result=myresult.getResult();
myresult.setResult(result.subList(0,maxItems));//maxItems=30在创建异步任务对象时设置它
返回我的结果;
}

您是否在Asyn类中处理Xml数据是的,在async类中会进行抓取和解析什么是AsyncTaskResult?您有它的实现吗?我添加了AsyncTaskResult
public MySecondAdapter(View a, ArrayList<HashMap<String, String>> id,int _ID_To_Show) {
    idfromhayoolafetch = id;
    myinflater = (LayoutInflater) AppContext.getAppContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ID_To_Show= _ID_To_Show;
}
public MySecondAdapter(View a, ArrayList<HashMap<String, String>> id) {
    idfromhayoolafetch = id;
    myinflater = (LayoutInflater) AppContext.getAppContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
    if(ID_To_Show>0){
        return ID_To_Show;  
    }else{
    return idfromhayoolafetch.size();
    }
    }
protected AsyncTaskResult<ArrayList<HashMap<String, String>>> doInBackground(
        String... arg0) {

        String xml = "Get String from my web service class"
        myXmlParsingClass myparser = new myXmlParsingClass (xml, "getitem");
        myparser .runParser();

        AsyncTaskResult<ArrayList<HashMap<String, String>>> myresult = new AsyncTaskResult<ArrayList<HashMap<String, String>>>(myXmlParsingClass .getParsedData());
        ArrayList<HashMap<String, String>> result=myresult.getResult();
        myresult.setResult(result.subList(0,maxItems));//maxItems=30 set it while creating async task object
        return myresult ;

    }