Android 为什么AsyncTask不在另一个AsynkTask的PostExecute方法中执行?

Android 为什么AsyncTask不在另一个AsynkTask的PostExecute方法中执行?,android,Android,我正在制作一个分区列表视图,其中第一个分区是挂起的请求列表,第二个分区已经是朋友。在列表视图的第一个分区中有两个按钮“接受”和“拒绝”。 当我点击accept时,点击服务器并更改Status,现在我的列表应该更新了,第一部分accept列表应该显示在listview第二部分的friendlist中。 我正在使用以下代码:- public class EntryAdapter extends ArrayAdapter<Item> { private Context context;

我正在制作一个分区列表视图,其中第一个分区是挂起的请求列表,第二个分区已经是朋友。在列表视图的第一个分区中有两个按钮“接受”和“拒绝”。 当我点击accept时,点击服务器并更改Status,现在我的列表应该更新了,第一部分accept列表应该显示在listview第二部分的friendlist中。 我正在使用以下代码:-

public class EntryAdapter extends ArrayAdapter<Item> {

private Context context;
private List<Item> items;
private LayoutInflater objlayoutinflator;
private PostJobImageLoader objimageLoader;
private ConnectionFriendListModle objmodle=null;

public EntryAdapter(Context context,List<Item> items) {
    super(context, 0, items);
    this.context = context;
    this.items = items;
    objlayoutinflator = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    objimageLoader = new PostJobImageLoader(context.getApplicationContext());
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View myview = convertView;

    final Item objitem = items.get(position);
    if (objitem != null) {
        if (objitem.isSection()) {
            SectionItem objsection = (SectionItem) objitem;
            myview = objlayoutinflator.inflate(R.layout.listviewsection,
                    null);

            myview.setOnClickListener(null);
            myview.setOnLongClickListener(null);
            myview.setLongClickable(false);

            final TextView sectionView = (TextView) myview
                    .findViewById(R.id.txtsection);
            sectionView.setText(objsection.getTitle());
        } else {
            objmodle = (ConnectionFriendListModle) objitem;
            myview = objlayoutinflator.inflate(R.layout.connectionlistrow,
                    null);
            final TextView title = (TextView) myview
                    .findViewById(R.id.jobtitleinjobbidalert);
            final TextView subtitle = (TextView) myview
                    .findViewById(R.id.jobsubtitle);
            final ImageView objimageview = (ImageView) myview
                    .findViewById(R.id.user_image);
            final Button objaccept = (Button) myview
                    .findViewById(R.id.btnaccept);
            final Button objreject = (Button) myview
                    .findViewById(R.id.btnreject);

            if (objmodle.getStatus().equalsIgnoreCase("pending")) {
                objaccept.setVisibility(View.VISIBLE);
                objreject.setVisibility(View.VISIBLE);
                title.setText(objmodle.getUsername());
                subtitle.setText(objmodle.getName());
                String url = objmodle.getPicture();
                objimageLoader.DisplayImage(AppConstants.IMAGE_BASE_URL
                        + url, objimageview);
            } else {
                objaccept.setVisibility(View.INVISIBLE);
                objreject.setVisibility(View.INVISIBLE);
                title.setText(objmodle.getUsername());
                subtitle.setText(objmodle.getName());
                String url = objmodle.getPicture();
                objimageLoader.DisplayImage(AppConstants.IMAGE_BASE_URL+url, objimageview);
            }

            objaccept.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {

                    new AcceptFriendRequest().execute(objmodle.getId(),"accepted");
                }
            });
            objreject.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v)
                {

                }
            });
        }
    }
    return myview;
}


 private class AcceptFriendRequest extends AsyncTask<String,Void,String>
    {
     ProgressDialog objprogress = new ProgressDialog(EntryAdapter.this.context);
     AppRequestHandler objApprequest = new AppRequestHandler();
     String objresponce="";
        @Override
        protected void onPreExecute() {
            objprogress.setMessage("Please Wait While Loading...");
            objprogress.show();
        }

        @Override
        protected String doInBackground(String... params) {
            objresponce = objApprequest.acceptRequest(params[0],params[1]);
            return objresponce;
        }

        @Override
        protected void onPostExecute(String result) {
            if(objprogress.isShowing())
            {
                objprogress.dismiss();
            }
            if(result.equals("0"))
            {
                SharedPreferences myPrefs = EntryAdapter.this.context.getSharedPreferences(
                        AppConstants.MYPREF, EntryAdapter.this.context.MODE_WORLD_READABLE);
                String userid = myPrefs.getString(AppConstants.USER_ID, "");

                                 //but when controll reach this line not execute this asynctask and niether update listview
                new GetAllConnectionDetail().equals("86");

            }
        }
    }

 private class GetAllConnectionDetail extends AsyncTask<String,Void,List<Item>>
    {
     ProgressDialog objprogress = new ProgressDialog(EntryAdapter.this.context);
     AppRequestHandler objApprequest = new AppRequestHandler();
     List<Item> objlistitem=null;
        @Override
        protected void onPreExecute() {
            objprogress.setMessage("Please Wait While Loading...");
            objprogress.show();
        }

        @Override
        protected List<Item> doInBackground(String... params) {
            objlistitem = objApprequest.connectionDetails(params[0]);
            return objlistitem;
        }

        @Override
        protected void onPostExecute(List<Item> result) {
            if(objprogress.isShowing())
            {
                objprogress.dismiss();
            }
              items.clear();
              items.addAll(result);
              notifyDataSetChanged();   
        }

    }
公共类入口适配器扩展了ArrayAdapter{
私人语境;
私人清单项目;
私有布局扁平化器objlayoutinflator;
私有PostJobImageLoader对象图像加载器;
私有连接FriendlistModle objmodle=null;
公共入口适配器(上下文、列表项){
超级(上下文,0,项);
this.context=上下文;
这个项目=项目;
ObjLayoutFlator=(LayoutFlater)上下文
.getSystemService(上下文布局\充气机\服务);
objimageLoader=new PostJobImageLoader(context.getApplicationContext());
}
@凌驾
公共视图getView(int位置、视图转换视图、视图组父视图){
视图myview=convertView;
final Item objitem=items.get(位置);
if(objitem!=null){
if(objitem.isSection()){
SectionItem对象Section=(SectionItem)对象项;
myview=ObjLayoutFlator.充气(R.layout.listviewsection,
无效);
myview.setOnClickListener(null);
myview.setOnLongClickListener(null);
myview.setLongClickable(false);
最终文本视图截面视图=(文本视图)myview
.findViewById(R.id.TXT部分);
sectionView.setText(objsection.getTitle());
}否则{
objmodle=(ConnectionFriendListModle)objitem;
myview=ObjLayoutFlator.充气(R.layout.connectionlistrow,
无效);
最终文本视图标题=(文本视图)myview
.findViewById(R.id.jobtitleinjobbidalert);
最终文本视图字幕=(文本视图)myview
.findViewById(R.id.jobsubtitle);
最终图像视图objimageview=(图像视图)myview
.findviewbyd(R.id.user\u图像);
最终按钮objacept=(按钮)myview
.findviewbyd(R.id.btnacept);
最终按钮objreject=(按钮)myview
.findviewbyd(R.id.btnject);
if(objmodle.getStatus().equalsIgnoreCase(“待定”)){
objacept.setVisibility(View.VISIBLE);
objreject.setVisibility(View.VISIBLE);
title.setText(objmodle.getUsername());
subtitle.setText(objmodle.getName());
字符串url=objmodle.getPicture();
objimageLoader.DisplayImage(AppConstants.IMAGE\u BASE\u URL
+url,objimageview);
}否则{
objacept.setVisibility(视图不可见);
objreject.setVisibility(View.INVISIBLE);
title.setText(objmodle.getUsername());
subtitle.setText(objmodle.getName());
字符串url=objmodle.getPicture();
DisplayImage(AppConstants.IMAGE\u BASE\u URL+URL,objimageview);
}
objaccept.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
新的AcceptFriendRequest().execute(objmodle.getId(),“accepted”);
}
});
objreject.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v)
{
}
});
}
}
返回myview;
}
私有类AcceptFriendRequest扩展异步任务
{
ProgressDialog objprogress=新建ProgressDialog(EntryAdapter.this.context);
AppRequestHandler objApprequest=新建AppRequestHandler();
字符串objresponse=“”;
@凌驾
受保护的void onPreExecute(){
setMessage(“加载时请稍候…”);
objprogress.show();
}
@凌驾
受保护的字符串doInBackground(字符串…参数){
objresponse=objApprequest.acceptRequest(参数[0],参数[1]);
返回objresponce;
}
@凌驾
受保护的void onPostExecute(字符串结果){
if(objprogress.isShowing())
{
objprogress.disclose();
}
如果(结果等于(“0”))
{
SharedReferences myPrefs=EntryAdapter.this.context.GetSharedReferences(
AppConstants.MYPREF,EntryAdapter.this.context.MODE\u WORLD\u READABLE);
字符串userid=myPrefs.getString(AppConstants.USER\u ID,“”);
//但是当controll到达这一行时,不要执行这个asynctask和niether更新listview
新的GetAllConnectionDetail()等于(“86”);
}
}
}
私有类GetAllConnectionDetail扩展了AsyncTask
{
ProgressDialog objprogress=新建ProgressDialog(EntryAdapter.this.context);
AppRequestHandler objApprequest=新建AppRequestHandler();
List objlistitem=null;
@凌驾
受保护的void onPreExecute(){
setMessage(“加载时请稍候…”);
objprogress.show();
}
@凌驾
受保护列表doInBackground(字符串…参数){
objlistitem=objApprequest.connectionDetails(参数[0]);
返回对象列表项;
}
@凌驾
受保护的void onPostExecute(列表结果){
if(objprogress.isShowing())
{
objprogress.disclose();
}
items.clear();
items.addAll(结果);
notifyDataSetChanged();
}
}
}

是一个