报错:E/RecyclerView: No adapter attached; skipping layout

底部导航页面弄了个列表渲染就出错了适配器我都设置了还报错没有适配器**,晕了,求大佬解决**
报错:E/RecyclerView: No adapter attached; skipping layout_第1张图片
报错:E/RecyclerView: No adapter attached; skipping layout_第2张图片
适配器部分
package com.example.myapp4;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.myapp4.R;

public class DingYueActivity extends AppCompatActivity {
private String[] dyTitles;
private String[] dyDescripts;
private int[] dyIcons;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.dingyue_fragment);

    initDYData();
    //从布局文件中获取名叫tv_dingyue的循环视图
    RecyclerView rcView=findViewById(R.id.rv_dingyue);
    //创建一个垂直方向的线性布局管理器

    LinearLayoutManager manager=new LinearLayoutManager(this);
    manager.setOrientation(LinearLayoutManager.VERTICAL);
    //设置布局视图的布局管理器
    rcView.setLayoutManager(manager);
    //设置列表的线性适配器
    rcView.setAdapter(new MyRCVAdapter());

}
private void initDYData() {
    dyTitles = new String[]{"我的图书馆", "所有应用", "热门报刊", "头条", "教育", "科技",
            "财经", "文史", "人文", "体育", "娱乐", "军事", "外文资讯", "自定义"};
    dyDescripts=new String[]{"图书馆自有RSS源","所有应用列表","热门报刊",
            "最新最全要闻频道,网罗国际国内新闻","集纳各类考试专题、教育资讯",
            "提供重要数码资讯、IT信息","提供全天候国内和世界财经新闻",
            "文史资料、文化热点","提供文化新闻、读书信息的新闻频道",
            "网罗国际国内各种体育资讯,展现体坛风云","实时传递娱乐八卦、影视动态",
            "第一时间发布便于军事动态","提供最新外文信息","添加自定义的RSS源"};
    dyIcons=new int[]{R.mipmap.ic_rss_gdslzs,R.mipmap.ic_rss_all_app,
            R.mipmap.ic_rss_newspapers,R.mipmap.ic_rss_front_page,R.mipmap.ic_rss_education,
            R.mipmap.ic_rss_technology,R.mipmap.ic_rss_finance,
            R.mipmap.ic_rss_literature_and_history,R.mipmap.ic_rss_culture,
            R.mipmap.ic_rss_sports,R.mipmap.ic_rss_pastime,R.mipmap.ic_rss_military,
            R.mipmap.ic_rss_information,R.mipmap.ic_rss_customize};
}
//适配器
public class MyRCVAdapter extends RecyclerView.Adapter{


    @NonNull
    //创建列表项的视图持有者
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        MyViewHolder holder= new MyViewHolder(
                LayoutInflater.from(parent.getContext()).inflate(R.layout.dingyue_item,parent,false));



        return holder;
    }
    //绑定列表项的视图持有者
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        ((MyViewHolder)holder).iv_icon.setImageResource(dyIcons[position]);
        ((MyViewHolder)holder).tv_title.setText(dyTitles[position]);
        ((MyViewHolder)holder).tv_descript.setText(dyDescripts[position]);

    }
    //获取列表项的个数
    public int getItemCount() {return  dyTitles.length;}

    class MyViewHolder extends RecyclerView.ViewHolder{
        TextView tv_title;
        TextView tv_descript;
        ImageView iv_icon;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            tv_title=itemView.findViewById(R.id.tv_dyTitle);
            tv_descript=itemView.findViewById(R.id.tv_dyDiscript);
            iv_icon=itemView.findViewById(R.id.iv_dyIcon);

        }

    }
}

}


    
    
        

        
    
    


    
    


你可能感兴趣的:(报错:E/RecyclerView: No adapter attached; skipping layout)