Recyclerview not displaying results on fragment

I'm trying to use recyclerview on a snippet with a dummy data sample, but it doesn't display any results in the snippets I made, but when I tried it on activity, the desired results show up in the class activity. Here is the method fragment manager I made to replace each fragment:

public void changeFragment(Fragment targetFragment) {
            .replace(, targetFragment)


and this is my current line of code to access the target snippet:

setOnItemClickListener(new DrawerItem.OnItemClickListener() {
                        public void onClick(DrawerItem drawerItem, long l, int i) {
                            changeFragment(new NewsFeedSantri().newInstance());


This is my adapter for creating dummy data:

public class NewsFeedAdapter extends RecyclerView.Adapter<NewsFeedAdapter.NewsFeedHolder> {

private List<NewsFeedItem> newsList;

public NewsFeedAdapter() {
    newsList = new ArrayList<NewsFeedItem>();
    NewsFeedItem nf = new NewsFeedItem();
    for (int i=1; i <= 20; i++) {
        nf.setNewsTittle("Judul Berita");
        nf.setNewsContent("Ini lorem ipsum dll");

public NewsFeedHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.
            inflate(R.layout.base_newsfeed_item, parent, false);
    NewsFeedHolder viewHolder = new NewsFeedHolder(itemView);
    return viewHolder;

public void onBindViewHolder(NewsFeedHolder holder, int position) {
    NewsFeedItem newsfeed = newsList.get(position);

public int getItemCount() {
    return newsList.size();

public class NewsFeedHolder extends RecyclerView.ViewHolder {
    protected TextView viewTittle;
    protected TextView viewUrl;
    protected TextView viewContent;
    protected TextView viewDate;

    public NewsFeedHolder(View itemView) {
        viewTittle = (TextView) itemView.findViewById(;
        viewDate = (TextView) itemView.findViewById(;
        viewContent = (TextView) itemView.findViewById(;


This is the NewsFeedItem class:

public class NewsFeedItem {
protected String idNewsTittle;
protected String newsTittle;
protected String newsUrl;
protected String newsContent;
protected String newsDate;

public String getIdNewsTittle() {
    return idNewsTittle;

public void setIdNewsTittle(String idNewsTittle) {
    this.idNewsTittle = idNewsTittle;

public String getNewsTittle() {
    return newsTittle;

public void setNewsTittle(String newsTittle) {
    this.newsTittle = newsTittle;

public String getNewsUrl() {
    return newsUrl;

public void setNewsUrl(String newsUrl) {
    this.newsUrl = newsUrl;

public String getNewsContent() {
    return newsContent;

public void setNewsContent(String newsContent) {
    this.newsContent = newsContent;

public String getNewsDate() {
    return newsDate;

public void setNewsDate(String newsDate) {
    this.newsDate = newsDate;


And this is my snippet:

public class NewsFeedSantri extends Fragment {

private RecyclerView recList;

public static NewsFeedSantri newInstance() {
    NewsFeedSantri fragment = new NewsFeedSantri();
    Bundle args = new Bundle();
    return fragment;

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.base_newsfeed_rcview, container, false);
    recList = (RecyclerView) rootView.findViewById(;
    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    NewsFeedAdapter nfa = new NewsFeedAdapter();
    return rootView;
} }


The error doesn't occur, that's what confuses me, am I missing something?


source to share

All Articles