登录 立即注册
安币:

各位大神,刚在学网络请求框架,请问这个要怎样添加请求参数??[复制链接]

https://blog.csdn.net/JArchie520/article/details/78794115 我用的是这篇博客大佬的框架,我模仿弄了个post请求出来,但我想传参数,不知道该怎么传,求大神解答下!!!

122513 223查看 · 1回复 · 2018-11-28 21:23 有用(0
共1个回答
经济 2018-12-26 09:57 回复

@Override

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragment3_item);
    queue = Volley.newRequestQueue(this);
    user_id = getIntent().getStringExtra("hand_id");
    Item_fragment3_layout a = new Item_fragment3_layout(Urils.TAB_A_3_iem,
            user_id);
    uril = a.json_string(user_id);

    initview();

    getJson();

}

private void initview() {
    fragment3_item_Step = (GridViewWithHeaderAndFooter) findViewById(R.id.fragment3_item_Step);
    text_fragment3activity_add_time = (TextView) findViewById(R.id.text_fragment3activity_add_time);
    imager_fragment3activity_host_pic_s = (ImageView) findViewById(R.id.imager_fragment3activity_host_pic_s);
    imager_fragment3activity_host_pic_s.setOnClickListener(new OnClickListener() {
        
        @Override
        public void onClick(View arg0) {
            Intent intent=new Intent(Fragment3_itemActivity.this,ItemActivity.class);
            intent.putExtra("user_id1",fragment.get(0).getUser_id());
            intent.putExtra("user_name", fragment.get(0).getUser_name());
            intent.putExtra("face_pic", fragment.get(0).getFace_pic());
            startActivity(intent);
        }
    });
    
    ll_linear=(LinearLayout) findViewById(R.id.ll_linear);
    ImageView fragment3_button = (ImageView) findViewById(R.id.fragment3_button);
    fragment3_button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            
             
        onBackPressed();

        }
    });

}

public void getJson() {
    StringRequest request = new StringRequest(uril, new Listener<String>() {

        @Override
        public void onResponse(String response) {

            try {
                JSONObject obj = new JSONObject(response);
                JSONObject item = obj.getJSONObject("data");
                String  user_id1=item.optString("user_id");
                String subject = item.optString("subject");
                String add_time = item.optString("add_time");
                String face_pic = item.optString("face_pic");
                 
                String user_name = item.optString("user_name");
                String host_pic_s = item.optString("host_pic_s");
             
                text_fragment3activity_user_name = (TextView) findViewById(R.id.text_fragment3activity_user_name);
                text_fragment3activity_user_name.setText(user_name);
                MyApp.loader.displayImage(face_pic, imager_fragment3activity_host_pic_s, MyApp.options);
                text_fragment3activity_add_time.setText(add_time);
                
                JSONArray comment_list = item.getJSONArray("comment_list");
                int len = comment_list.length();
                for (int i = 0; i < len; i++) {

                    JSONObject cl = comment_list.getJSONObject(i);
                    String add_time1 = cl.optString("add_time");// 鏃堕棿
                    String avatar = cl.optString("avatar");// 澶村儚
                    String user_name1 = cl.optString("user_name");
                    String comment = cl.optString("comment");
                    comment_list1 com = new comment_list1(add_time1,
                            avatar, user_name1, comment);
                    alist.add(com);
                }
             
                
                JSONArray step = item.getJSONArray("step");
                int lent = step.length();
                for (int i = 0; i < lent; i++) {

                    JSONObject sp = step.getJSONObject(i);
                    String pic = sp.optString("pic");
                    String content = sp.optString("content");
                    Step1 st = new Step1(pic, content);
                    blist.add(st);
                }
                if (0 != blist.size()) {
                    listAdapter.notifyDataSetChanged();
                }
                fragment3_listview_item fli = new fragment3_listview_item( subject,   host_pic_s,
                          add_time,   user_name,   face_pic,   blist,
                        alist,   user_id1);
                fragment.add(fli);

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    }, new ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {

        }
    });
    queue.add(request);
    listAdapter = new fragment3Activity_itemAdapter(this, blist);
    getJson1();
View view =getLayoutInflater().inflate(R.layout.activity_fragment3_item_step, null);
GridView fragment3_item_comment_list=(GridView) view.findViewById(R.id.fragment3_item_comment_list);
comAdapter=new fragment3activity_item_comAdapter(this, alist);
fragment3_item_Step.addHeaderView(view, alist, false);
fragment3_item_comment_list.setAdapter(comAdapter);

    fragment3_item_Step.setAdapter(listAdapter);

}
需要登入后才可以评论 登录 | 立即注册

联系我们
关闭
合作电话:
15618560077
Email:
805941275@qq.com
商务市场合作/投稿
问题反馈及帮助
联系我们

广告投放| 下载客户端|申请友链|手机版|站点统计|安卓巴士 ( 粤ICP备15117877号 )

返回顶部 返回版块