Search in sources :

Example 1 with NewsAdapter

use of com.lauren.simplenews.news.NewsAdapter in project SimpleNews by liuling07.

the class NewsListFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_newslist, null);
    mSwipeRefreshWidget = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_widget);
    mSwipeRefreshWidget.setColorSchemeResources(R.color.primary, R.color.primary_dark, R.color.primary_light, R.color.accent);
    mSwipeRefreshWidget.setOnRefreshListener(this);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recycle_view);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mAdapter = new NewsAdapter(getActivity().getApplicationContext());
    mAdapter.setOnItemClickListener(mOnItemClickListener);
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.addOnScrollListener(mOnScrollListener);
    onRefresh();
    return view;
}
Also used : NewsAdapter(com.lauren.simplenews.news.NewsAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) NewsView(com.lauren.simplenews.news.view.NewsView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 NewsAdapter (com.lauren.simplenews.news.NewsAdapter)1 NewsView (com.lauren.simplenews.news.view.NewsView)1