Here is my code
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_contracts, container, false); Log.d(TAG, "Start"); Thread thread = new Thread(runnable); thread.start(); List<ItemObject> rowListItem = getAllItemList(); lLayout = new LinearLayoutManager(getActivity()); RecyclerView rView = (RecyclerView)view.findViewById(R.id.recycler_view); rView.setLayoutManager(lLayout); RecyclerViewAdapter rcAdapter = new RecyclerViewAdapter(getActivity(), rowListItem); rView.setAdapter(rcAdapter); return view; } Handler handler = new Handler(); public Runnable runnable = new Runnable() { @TargetApi(Build.VERSION_CODES.KITKAT) public void run() { String token = getActivity().getIntent().getExtras().getString("access_token"); Log.d(TAG, token); DefaultHttpClient hc = new DefaultHttpClient(); ResponseHandler GetResponse = new BasicResponseHandler(); HttpGet http = new HttpGet("http://mysite/api/v1.3.0/contract/getlist?access_token="+token); try { String response = (String) hc.execute(http, GetResponse); Log.d(TAG, response); JSONObject jobj = new JSONObject(response); JSONArray contracts = jobj.getJSONArray("contracts"); String contract = contracts.getString(0); int l = contracts.length(); for (int i=0;i<l;i++){ names[i] = names[i] + contracts.getString(i); Log.d(TAG, names[i]); } } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } }; private List<ItemObject> getAllItemList(){ List<ItemObject> allItems = new ArrayList<ItemObject>(); allItems.add(new ItemObject(names[1], "6")); allItems.add(new ItemObject("Мои обращения", "2")); allItems.add(new ItemObject("Ближайший офис", "3")); allItems.add(new ItemObject("Заказать звонок", "4")); allItems.add(new ItemObject("Позвонить в контактный центр", "5")); return allItems; } I need to load information from the names array into cardview. But the information does not have time to load, RecyclerView is created faster than the stream ends. What do you advise?
notifyDataSetChanged()list? - pavlofff