大佬教程收集整理的这篇文章主要介绍了android – 将项目添加到recyclerview的顶部,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
public void refreshing() throws IllegalStateException{ new AsyncTask<String,Void,Void>() { @Override protected void onPreExecute() { super.onPreExecute(); progressBar.setVisibility(View.VISIBLE); } @Override protected Void doInBACkground(String... arg0) { final List<NameValuePair> list = new ArrayList<NameValuePair>(); list.add(new BasicNameValuePair("id",sPreferences.getString("ID",""))); final httpParams httpParams = new BasichttpParams(); httpconnectionParams.setConnectionTimeout(httpParams,30000); DefaulthttpClient httpClient = new DefaulthttpClient(httpParams); httpPost httpPost = new httpPost(Config.requestpatienthistory); httpPost.getParams().setBooleanParameter(CoreProtocolPNameS.USE_EXPECT_CONTinUE,falsE); try { httpPost.setEntity(new UrlEncodedFormEntity(list)); } catch (IOException E) { e.printStackTrace(); } try { httpResponse response = httpClient.execute(httpPost); BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String json = reader.readLine(); JSONObject jsonObj = new JSONObject(json); if (jsonObj.has("control")) { JSONArray FeedArray = jsonObj.getJSONArray("control"); for (int i = 0; i < FeedArray.length(); i++) { JSONObject FeedObj = (JSONObject) FeedArray.get(i); final Historyitem item = new Historyitem(); if (FeedObj.has("Reported_Time")) { item.setReported_Time(FeedObj.getString("Reported_Time")); } historyitems.add(item); } } else { System.out.println("" + "no patients"); } } catch (SocketException E) { e.printStackTrace(); } catch (JSONException E) { e.printStackTrace(); } catch (NullPointerException E) { e.printStackTrace(); }catch (Exception E) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); progressBar.setVisibility(View.GONE); historyadapter = new HistoryRecyclelistadapter(getActivity(),getActivity(),historyitems); hisrecyclerview.setAdapter(historyadapter); } }.execute(); }
以上是大佬教程为你收集整理的android – 将项目添加到recyclerview的顶部全部内容,希望文章能够帮你解决android – 将项目添加到recyclerview的顶部所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。