-1

我正在制作一个部分列表视图,其中第一个部分是待处理的请求列表,第二个部分已经是朋友,在列表视图的第一部分有两个按钮接受和拒绝。当我单击接受命中服务器并更改状态时,现在我的列表应该更新,并且第一部分接受列表应该显示在列表视图第二部分的好友列表中。我正在使用以下代码:-

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();   
        }

    }

}

我的方向是对还是错,请任何人帮助我为什么它不起作用......

4

1 回答 1

2

你必须GetAllConnectionDetail通过调用它的execute方法来开始你的任务,似乎你不这样做。

于 2012-09-06T13:42:46.880 回答