@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list, null); mRecyclerView = (RecyclerView) root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new Adapter(); mRecyclerView.setAdapter(mAdapter); mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
@Override public void onPostExecute() { list.clear(); try { JSONObject jsonObject = new JSONObject(sb); JSONArray jsonArray = jsonObject.getJSONArray("list"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject c = jsonArray.getJSONObject(i); String title = c.getString("title"); String nicname = c.getString("nicname"); String content = c.getString("content"); int count = c.getInt("count"); int number = c.getInt("number"); int reply_count = c.getInt("reply_count"); String day = c.getString("day"); list.add( new Item( number, count, title, content, nicname, Date.valueOf(day), View.GONE, reply_count)); } } catch (Exception e) { } LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity()); linearLayoutManager.setOrientation(linearLayoutManager.VERTICAL); adapter = new NoticeBoardAdapter(getActivity(), list); recyclerView.setAdapter(adapter); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); refreshLayout.setRefreshing(false); }
private void initView() { title = new MyTitleBarHelper(this, getWindow().getDecorView().findViewById(android.R.id.content)); title.setMiddleText("常用电话"); title.setOnclickListener(this); keeperTitle = (TextView) findViewById(R.id.my_title_tel); wuyeKeeper = (TextView) findViewById(R.id.tv_wuye); keeperTel = (TextView) findViewById(R.id.tv_tel); cell = (RelativeLayout) findViewById(R.id.phone_line_one); cellTitle = (TextView) findViewById(R.id.my_title_tel); img_tel_one = (ImageView) findViewById(R.id.img_tel_one); ll_wuye_keeper = (LinearLayout) findViewById(R.id.ll_wuye_keeper); // commTel = (TextView) findViewById(R.id.tel1); iv_title_bar_left = (ImageView) findViewById(R.id.iv_title_bar_left); tv_tel_pager = (TextView) findViewById(R.id.tv_tel_pager); // 创建布局管理器 mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view); LinearLayoutManager mLayoutManager = new LinearLayoutManager(this); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); adapter = new MyTelRecycleAdapter(); adapter.setOnItemClickListener(this); mRecyclerView.setAdapter(adapter); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tarot_feedback); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); final ActionBar ab = getSupportActionBar(); ab.setDisplayHomeAsUpEnabled(false); FloatingActionButton fablogin = (FloatingActionButton) findViewById(R.id.fab_login); fablogin.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(getUsername())) { facebookLogin(); } else { addFeedback(getUsername()); } } }); RecyclerView rv = (RecyclerView) findViewById(R.id.recyclerview); rv.setHasFixedSize(true); LinearLayoutManager llm = new LinearLayoutManager(this); llm.setOrientation(LinearLayoutManager.VERTICAL); rv.setLayoutManager(llm); updateList(); }
/** 初始化RecyclerView */ public void initRecyclerView() { final LinearLayoutManager manager = new LinearLayoutManager(getActivity()); manager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(manager); mRecyclerView.addOnScrollListener( new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); int num = manager.findLastVisibleItemPosition(); // 只有滑动到了倒数第三个item,且没有数据在加载时,才去访问接口 // cacheList.size()-1 是滑动到了底部 , dy>0表示在向下滑动 if ((num == cacheList.size() - 3 || num == cacheList.size() - 1) && dy > 0 && !isLoading && Application.connectedType == ConnectivityManager.TYPE_WIFI) { String url = Interface.fuliImageUrl + "&page=" + page + "&page_size=15&max_timestamp=" + cacheList.get(cacheList.size() - 1).getUpdate_time() + "&latest_viewed_ts=" + cacheList.get(0).getUpdate_time(); adapter.addFooterView(getActivity(), R.layout.refresh_progress_bar, 0, 0, 0, 0); isLoading = true; HttpUtils.get(url, new GetData(true)); } } }); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_item_detail, container, false); // click on category in list OpenHoursManager lm = new OpenHoursManager(getActivity()); String[] categories = { "library", "info", "cafeteria_gar", "cafeteria_grh", "cafeteria", "cafeteria_pas", "cafeteria_wst" }; Cursor c = lm.getAllHoursFromDb(categories[mItemId]); RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.fragment_item_detail_recyclerview); recyclerView.setAdapter(new OpeningHoursDetailAdapter(c)); final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(layoutManager); recyclerView.setHasFixedSize(true); return rootView; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); ButterKnife.bind(this); Log.d(TAG, "Cars in list: " + cars.size()); // homeFab.attachToListView(carList); LinearLayoutManager llm = new LinearLayoutManager(this); llm.setOrientation(LinearLayoutManager.VERTICAL); carList.setLayoutManager(llm); carAdapter = new CarAdapter(cars, Home.this); carList.setAdapter(carAdapter); registerForContextMenu(carList); carAdapter.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(View view, int position) { Intent carPage = new Intent(getApplicationContext(), CarPage.class); Bundle b = new Bundle(); b.putString("vin", cars.get(position).getVin()); carPage.putExtras(b); startActivity(carPage); } @Override public void onItemLongClick(View view, int position) { Log.d(TAG, "ITEM WAS LONG PRESSED!"); openContextMenu(view); selectedPosition = position; } }); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_history, container, false); swipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeRefesh); recyclerView = (RecyclerView) v.findViewById(R.id.historylist); swipeRefreshLayout.setColorSchemeColors(Color.RED, Color.GREEN, Color.BLUE); swipeRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { swipeRefreshLayout.postDelayed( new Runnable() { @Override public void run() { getContext().startService(new Intent(getContext(), CloudSyncService.class)); recyclerView.setAdapter(new HistoryListAdapter(checkUpDAO.getAll())); swipeRefreshLayout.setRefreshing(false); } }, 300); } }); LinearLayoutManager l = new LinearLayoutManager(getActivity()); l.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(l); recyclerView.setAdapter(new HistoryListAdapter(checkUpDAO.getAll())); return v; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listContact = new ArrayList<>(); Contact john = new Contact("John", "Hudson", "555-5555", "*****@*****.**"); Contact bill = new Contact("Bill", "Nye", "555-5554", "*****@*****.**"); Contact neil = new Contact("Neil", "Tyson", "555-5553", "*****@*****.**"); Contact phil = new Contact("Phil", "Plait", " 555-5552", "*****@*****.**"); Contact nikola = new Contact("Nikola", "Tesla", "555-5551", "*****@*****.**"); listContact.add(john); listContact.add(bill); listContact.add(neil); listContact.add(phil); listContact.add(nikola); RecyclerView recyclerView; recyclerView = (RecyclerView) findViewById(R.id.contact_list); ContactList contactList = new ContactList(); recyclerView.setAdapter(contactList); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getBaseContext()); linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(linearLayoutManager); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recycle_swipetolayout); swipeToLoadLayout = ((SwipeToLoadLayout) findViewById(R.id.swipeToLoadLayout)); mRecycleView = ((RecyclerView) findViewById(R.id.swipe_target)); adapter = new HomeAdapter(); // 设置垂直的线性布局管理器,Orientation --> VERTICAL:垂直 HORIZONTAL:水平 LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); // StaggeredGridLayoutManager layoutManager = new // StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL); // 添加分割线 mRecycleView.addItemDecoration( new DividerItemDecoration(getApplicationContext(), DividerItemDecoration.VERTICAL_LIST)); mRecycleView.setLayoutManager(layoutManager); mRecycleView.setItemAnimator(new DefaultItemAnimator()); mRecycleView.setAdapter(adapter); adapter.refresh(); /** 设置下拉刷新和上拉加载监听 */ swipeToLoadLayout.setOnRefreshListener(this); swipeToLoadLayout.setOnLoadMoreListener(this); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { Bus bus = ((ApplicationModified) getActivity().getApplication()).getBus(); bus.register(this); View myFragment = inflater.inflate(R.layout.fragment_main, container, false); recList = (RecyclerView) myFragment.findViewById(R.id.card_list); recList.setHasFixedSize(true); LinearLayoutManager llm = new LinearLayoutManager(this.getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); recList.setLayoutManager(llm); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { String title = ((TextView) v.findViewById(R.id.title)).getText().toString(); ((BaseActivity) getActivity()).openArticle(title); } }; ArticlesAdapter articlesAdapter; if (articlesList == null) { articlesAdapter = new ArticlesAdapter(listener); new ServiceHelper().getSavedArticles(this.getActivity()); } else { articlesAdapter = new ArticlesAdapter(listener, articlesList); } recList.setAdapter(articlesAdapter); if (noResults) { TextView no_Results = (TextView) myFragment.findViewById(R.id.NoResultMessage); no_Results.setVisibility(View.VISIBLE); } return myFragment; }
@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); EventManager eventManager = EventManager.getInstance(); RecyclerView recList = (RecyclerView) rootView.findViewById(R.id.event_recycler_view); mType = getArguments().getInt(TYPE); recList.setHasFixedSize(true); LinearLayoutManager llm = new LinearLayoutManager(mContext); llm.setOrientation(LinearLayoutManager.VERTICAL); recList.setLayoutManager(llm); mAdapter = new EventRecyclerViewAdapter(mContext, eventManager); recList.setAdapter(mAdapter); switch (mType) { case ACCEPTED: mAdapter.updateEventList(eventManager.getAcceptedEvents()); break; case DECLINED: mAdapter.updateEventList(eventManager.getDeclinedEvents()); break; } return rootView; }
private void setupRecyclerView() { layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(ThreadListActivity.this)); mAdapter = new ThreadListAdapter( this, mSubForum == null ? mMainForum.getForumId() : mSubForum.getSubForumId(), mThreadList); mRecyclerView.setAdapter(mAdapter); mRecyclerView.addOnScrollListener( new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); int lastVisibleItem = layoutManager.findLastVisibleItemPosition(); if (dy > 0 && lastVisibleItem >= mThreadList.size() - 4 && !mIsLoading) { // 拉取数据,显示进度 Log.i(TAG, "onScrolled >> 即将到底,准备请求新数据"); mThreadList.add(null); mAdapter.notifyItemInserted(mThreadList.size() - 1); refreshData(mCurrentPosition, mCurrentPosition + BUApplication.LOADING_THREADS_COUNT); mIsLoading = true; } } }); }
@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_layout_conversations, container, false); setTitle("Conversas"); conversationsList = new ArrayList<>(); conversationsList = generateConversationList(); conversationsAdapter = new ConversationsAdapter(conversationsList); rvConversations = (RecyclerView) view.findViewById(R.id.recycler_conversations); final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); rvConversations.setLayoutManager(layoutManager); rvConversations.setAdapter(conversationsAdapter); rvConversations.addOnItemTouchListener( new RecyclerItemClickListener( getContext(), new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) { openConversation(position); } })); return view; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayShowHomeEnabled(true); View rootView = inflater.inflate(R.layout.fragment_weapon_list, container, false); RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.listview_landing_menu); recyclerView.setAdapter(new LandingMenuAdapter(getActivity())); recyclerView.setHasFixedSize(true); ItemClickSupport.addTo(recyclerView) .setOnItemClickListener( new ItemClickSupport.OnItemClickListener() { @Override public void onItemClicked(RecyclerView recyclerView, int position, View v) { Log.e("Listener", "anda"); } }); final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(layoutManager); return rootView; }
@Override public void onBindViewHolder(final CashierAdapter.ViewHolder holder, final int position) { final KitchenOpen item = getItem(position); holder.vTextBillNo.setText(item.getOrderid()); mOrderId = item.getOrderid(); // float mServiceTax = item.getTotalamount() * 13 / 100; // mTotalAmount = item.getTotalamount() + mServiceTax; holder.vTextTotalAmount.setText("TOTAL AMOUNT : " + item.getTotalamount() + ""); holder.vTextTableNo.setText("" + item.getTableid()); // TODO FIX SOME LATE BUG HERE holder.vCashierCard.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (cashierClickListner != null) { mOrderId = item.getOrderid(); cashierClickListner.itemClicked( v, mOrderId, item.getSno(), item.getTableid(), item.getTotalamount()); return true; } else { return false; } } }); initFirebase(mOrderId); // RECYCLER VIEW mMyAdapter = new CashierItemAdapter(mQuery, Order.class, mAdapterItems, mAdapterKeys); LinearLayoutManager linearLayout = new LinearLayoutManager(context); linearLayout.setOrientation(LinearLayoutManager.VERTICAL); holder.recyclerView.setLayoutManager(linearLayout); holder.recyclerView.setLayoutManager(new LinearLayoutManager(context)); holder.recyclerView.setAdapter(mMyAdapter); holder.recyclerView.setEnabled(false); String mActiveLink = context.getResources().getString(R.string.FireBase_Delivery_URL) + "/" + mOrderId; final Firebase mRef = new Firebase(mActiveLink); mRef.addValueEventListener( new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { boolean vExist = dataSnapshot.exists(); if (vExist) { Delivery post = dataSnapshot.getValue(Delivery.class); holder.vTextTableNo.setText( "" + String.format("%1$.2f", post.getMobileno()).split("\\.")[0]); } } @Override public void onCancelled(FirebaseError firebaseError) { System.out.println("The read failed: " + firebaseError.getMessage()); } }); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_visit, container, false); context = getActivity(); visit_id = getArguments().getString("visit_id"); pdv_id = getArguments().getString("pdv_id"); pdv = getArguments().getString("pdv"); credit = getArguments().getString("credit_line"); pdv_rfc = getArguments().getString("pdv_rfc"); GPSTracker tracker = new GPSTracker(getActivity()); latitude = tracker.getLatitude(); longitude = tracker.getLongitude(); Log.d(LOG_VISIT_FRAGMENT, "PDV VISITADO: " + pdv_id); TrackerManager.sharedInstance().addInfoToCurrentUtils("id_pdv", pdv_id); TextView txt_header = (TextView) view.findViewById(R.id.txt_header); txt_header.setText(pdv); lst_step_visit = (RecyclerView) view.findViewById(R.id.lst_step_visit); lst_step_visit.setHasFixedSize(true); LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); lst_step_visit.setLayoutManager(llm); // checkin = WorkPlan.getCheckInByVisitID(getActivity(),visit_id); currentCheckin = CheckIn.getActiveMap(getActivity(), visit_id); if (currentCheckin.size() > 0) checkin = "active"; else checkin = "noactive"; if (FormAnswers.getMapByVisitID(context, visit_id).size() > 0) form = "form"; else form = "noform"; adapter = new StepVisitsAdapter(createListData(), getActivity(), checkin, form); adapter.listener = this; lst_step_visit.setAdapter(adapter); bundle = new Bundle(); bundle.putString("pdv_id", pdv_id); bundle.putString("pdv", pdv); bundle.putString("visit_id", visit_id); bundle.putString("latitude", String.valueOf(latitude)); bundle.putString("longitude", String.valueOf(longitude)); bundle.putString("pdv_rfc", pdv_rfc); bundle.putString("credit_line", credit); checkoutFlag = false; return view; }
private RecyclerView.LayoutManager getLayoutManager(int type) { LinearLayoutManager manager = new LinearLayoutManager(this); if (type == TYPE_GRID) { return new GridLayoutManager(this, GRID_SPAN_COUNT); } else if (type == TYPE_HORIZONTAL) { manager.setOrientation(LinearLayoutManager.HORIZONTAL); } else if (type == TYPE_VERTICAL) { manager.setOrientation(LinearLayoutManager.VERTICAL); } else if (type == TYPE_STAGGERED_V) { return new StaggeredGridLayoutManager( STAGGERED_SPAN_COUNT, StaggeredGridLayoutManager.VERTICAL); } else if (type == TYPE_STAGGERED_H) { return new StaggeredGridLayoutManager( STAGGERED_SPAN_COUNT, StaggeredGridLayoutManager.HORIZONTAL); } return manager; }
private void initRecyclerView(RecyclerView recyclerView) { recyclerView.setHasFixedSize(true); recyclerView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity()); recyclerView.setLayoutManager(mLayoutManager); ((LinearLayoutManager) mLayoutManager).setOrientation(LinearLayoutManager.VERTICAL); }
private void initRecyclerView() { recyclerview = (RecyclerView) findViewById(R.id.recyclerview); final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext()); linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerview.setLayoutManager(linearLayoutManager); adapter = new RecyclerViewAdapter(MainActivity.this, dataSet, recyclerview); recyclerview.setAdapter(adapter); }
private void initImageList() { if (null == imageListAdapter) { imageListAdapter = new ReplyWidgetImageListAdapter(this); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context); linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setAdapter(imageListAdapter); } }
protected void initViews(View view) { mErrorLayout = (EmptyLayout) view.findViewById(R.id.error_layout); mErrorLayout.setOnLayoutClickListener( new OnClickListener() { @Override public void onClick(View v) { mCurrentPage = 0; mState = STATE_REFRESH; mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); requestData(true); } }); mSwipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.srl_refresh); mSwipeRefresh.setColorSchemeResources( R.color.main_green, R.color.main_gray, R.color.main_black, R.color.main_purple); mSwipeRefresh.setOnRefreshListener( new OnRefreshListener() { @Override public void onRefresh() { refresh(); } }); mRecyclerView = (RecyclerView) view.findViewById(R.id.recycleView); mRecyclerView.setOnScrollListener(mScrollListener); if (isNeedListDivider()) { mRecyclerView.addItemDecoration( new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST)); } mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setHasFixedSize(false); if (mAdapter != null) { mRecyclerView.setAdapter(mAdapter); mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); } else { mAdapter = getListAdapter(); mAdapter.setOnItemClickListener(this); mAdapter.setOnItemLongClickListener(this); mRecyclerView.setAdapter(mAdapter); if (requestDataIfViewCreated()) { mCurrentPage = 0; mState = STATE_REFRESH; mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); new ReadCacheTask(this).execute(); } else { mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); } } if (mStoreEmptyState != -1) { mErrorLayout.setErrorType(mStoreEmptyState); } if (!TextUtils.isEmpty(mStoreEmptyMessage)) { mErrorLayout.setErrorMessage(mStoreEmptyMessage); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_society_event_upload_requests, container, false); ButterKnife.bind(this, view); mLayoutNoRecord = (LinearLayout) view.findViewById(R.id.layout_no_record); mLayoutNoConnection = (LinearLayout) view.findViewById(R.id.layout_no_network); final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(layoutManager); mSwipeContainer.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { if (new BaseActivity().isNetworkAvailable(getActivity())) { refresh(); } else { shortToast(getActivity(), "Network not available, failed to refresh"); mSwipeContainer.setRefreshing(false); } } }); mSwipeContainer.setColorSchemeResources( R.color.colorBlue, R.color.colorRed, R.color.colorGreen); mRecyclerView.addOnScrollListener( new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { int topRowVerticalPosition = (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop(); mSwipeContainer.setEnabled(topRowVerticalPosition >= 0); } @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } }); if (isNetworkAvailable(getContext()) == true) { new GetJson(GET_UPLOAD_REQUEST_URL).execute(); } else { mRecyclerView.setVisibility(View.GONE); mLayoutNoConnection.setVisibility(View.VISIBLE); mSwipeContainer.setEnabled(false); mSwipeContainer.setRefreshing(false); } return view; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = null; try { view = inflater.inflate(R.layout.zy_discovery_item_fragment, container, false); tag = OkHttpClientManager.getTag(); data_empty = view.findViewById(R.id.data_empty); mSwipeRefreshWidget = (CustomSwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_widget); click_refresh_btn = (Button) view.findViewById(R.id.click_refresh_btn); click_refresh_btn.setOnClickListener(this); app_progress_bar = view.findViewById(R.id.app_progress_bar); discovery_recyclerview = (RecyclerView) view.findViewById(R.id.discovery_recyclerview); // 设置布局管理器 vlinearLayoutManager = new LinearLayoutManager(getActivity()); vlinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); discovery_recyclerview.setLayoutManager(vlinearLayoutManager); newAdapter = new DiscoveryItemNewAdapter(getContext(), this); discovery_recyclerview.setAdapter(newAdapter); mSwipeRefreshWidget.setColorSchemeResources(R.color.google_blue); mSwipeRefreshWidget.setOnRefreshListener( new CustomSwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mSwipeRefreshWidget.setRefreshing(true); Log.i("test", "ZY_DiscoveryItemFragment===onCreate"); refresh(); } }); discovery_recyclerview.setOnScrollListener( new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItem + 1 == newAdapter.getItemCount()) { newAdapter.setShowLoading(true); getDiscoveryServer(); } } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); lastVisibleItem = vlinearLayoutManager.findLastVisibleItemPosition(); } }); getDiscoveryServer(); } catch (Exception e) { } return view; }
private void initData() { LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(this); mLinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRvPhoneBooks.setLayoutManager(mLinearLayoutManager); mPhoneBookList = new ArrayList<PhoneBook>(); getTelePhones(); PhoneBookAdapter adapter = new PhoneBookAdapter(this, mPhoneBookList); mRvPhoneBooks.setAdapter(adapter); }
@Override public void onResume() { super.onResume(); recyclerView = (RecyclerView) getView().findViewById(R.id.cardList); LinearLayoutManager llm = new LinearLayoutManager(getContext()); llm.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(llm); recyclerView.setHasFixedSize(true); new BackgroundTask().execute(); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); roundList.setLayoutManager(llm); roundList.setHasFixedSize(true); roundList.setAdapter(roundListAdapter); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { recyclerView = (RecyclerView) view.findViewById(R.id.upcomgingMovieList); LinearLayoutManager layoutManager = new LinearLayoutManager(this.getActivity()); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(layoutManager); UpcomingMoviesAsyncTask asyncTask = new UpcomingMoviesAsyncTask(recyclerView); asyncTask.execute(); }
/** CAST THE LAYOUT ELEMENTS * */ private void castLayoutElements() { linlaHeaderProgress = (LinearLayout) findViewById(R.id.linlaHeaderProgress); listTables = (RecyclerView) findViewById(R.id.listTables); linlaEmpty = (LinearLayout) findViewById(R.id.linlaEmpty); /** CONFIGURE THE RECYCLERVIEW * */ listTables.setHasFixedSize(false); LinearLayoutManager llm = new LinearLayoutManager(TableSelector.this); llm.setOrientation(LinearLayoutManager.VERTICAL); listTables.setLayoutManager(llm); }
@Override public View createView(ViewGroup viewGroup) { View v = mLf.inflate(R.layout.wifi_list, null); rcvWifiList = (RecyclerView) v.findViewById(R.id.rcyWifiList); LinearLayoutManager manager = new LinearLayoutManager(context); manager.setOrientation(LinearLayoutManager.VERTICAL); rcvWifiList.setLayoutManager(manager); adapter = new MyAdapter(context); rcvWifiList.setAdapter(adapter); return v; }