У меня есть эта плавающая кнопка действия, которая откроет диалоговое окно, где список предметов в программе recyclerView.но я получаю эту ошибку «Попытка вызвать виртуальный метод» void androidx.recyclerview.widget.RecyclerView.setLayoutManager (androidx.recyclerview.widget.RecyclerView $ LayoutManager) 'для ссылки на пустой объект "
Это мойадаптер:
public class UpdateListAdapter extends
RecyclerView.Adapter<UpdateListAdapter.ViewHolder> {
public List<String> fileDoneList;
public List<String> fileNameList;
public UpdateListAdapter(List<String>fileNameList,List<String>fileDoneList){
this.fileNameList = fileNameList;
this.fileDoneList = fileDoneList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.popup_list_items,parent,false);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
String fileName = fileNameList.get(position);
holder.fileNameView.setText(fileName);
}
@Override
public int getItemCount() {
return fileNameList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
View mView;
public TextView fileNameView;
public ImageView fileDoneView;
public ViewHolder(View itemView){
super(itemView);
mView = itemView;
fileNameView = (TextView) mView.findViewById(R.id.post_fileType);
fileDoneView = (ImageView) mView.findViewById(R.id.post_file_status);
}
}
}
это мои popup_list_items:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="10"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/post_file_icon"
android:src="@mipmap/file_icon"
android:layout_width="40dp"
android:layout_height="40dp">
</ImageView>
<TextView
android:id="@+id/post_fileType"
android:layout_width="wrap_content"
android:gravity="center_vertical"
android:text="Filename.type"
android:layout_weight="6"
android:layout_height="match_parent">
</TextView>
<ImageView
android:id="@+id/post_file_status"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:src="@mipmap/progress">
</ImageView>
</LinearLayout>
</RelativeLayout>
это мой xml с recyclerView2
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/post_userimg"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="28dp"
android:layout_marginLeft="28dp"
android:layout_marginTop="28dp"
android:layout_marginEnd="51dp"
android:layout_marginRight="51dp"
android:src="@mipmap/user_profile"
app:layout_constraintEnd_toStartOf="@+id/post_username"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/post_username"
android:layout_width="200dp"
android:layout_height="45dp"
android:textColor="@color/colorAccent"
android:textAllCaps="true"
android:textSize="18sp"
android:layout_marginTop="40dp" />
</LinearLayout>
<EditText
android:id="@+id/post_name"
android:layout_width="200dp"
android:layout_height="45dp"
android:layout_marginTop="48dp"
android:background="@drawable/round_post_txt"
android:hint="Title"
android:textColorHint="#000000"
android:inputType="textPersonName" />
<EditText
android:id="@+id/post_tags"
android:layout_width="200dp"
android:layout_height="45dp"
android:layout_marginTop="20dp"
android:textColorHint="#000000"
android:background="@drawable/round_post_txt"
android:hint="Tags"
android:inputType="textPersonName" />
<EditText
android:id="@+id/post_desc"
android:layout_width="200dp"
android:layout_height="45dp"
android:layout_marginTop="20dp"
android:textColorHint="#000000"
android:background="@drawable/round_post_txt"
android:hint="Description"
android:inputType="textPersonName" />
<ImageButton
android:id="@+id/post_imgbtn"
android:layout_width="200dp"
android:layout_height="55dp"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:layout_gravity="center"
android:layout_marginTop="28dp"
android:src="@mipmap/upload_btn"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="12dp">
</androidx.recyclerview.widget.RecyclerView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/post_button"
android:layout_width="250dp"
android:layout_height="45dp"
android:layout_marginTop="54dp"
android:background="@drawable/round"
android:text="Submit"
android:textAlignment="center"
android:textColor="@color/colorAccent"
android:textSize="18sp"
android:layout_marginBottom="32dp"/>
<ProgressBar
android:id="@+id/post_progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/post_button"
android:layout_alignLeft="@+id/post_button"
android:layout_alignTop="@+id/post_button"
android:layout_alignEnd="@+id/post_button"
android:layout_alignRight="@+id/post_button"
android:layout_alignBottom="@+id/post_button"
android:layout_marginStart="97dp"
android:layout_marginLeft="97dp"
android:layout_marginTop="-2dp"
android:layout_marginEnd="105dp"
android:layout_marginRight="105dp"
android:layout_marginBottom="0dp" />
</RelativeLayout>
</LinearLayout>
этоэто: где ошибка, я должен добавить снимок экрана также:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home2);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mAuth = FirebaseAuth.getInstance();
currentUser = mAuth.getCurrentUser();
mButton = (ImageButton) findViewById(R.id.post_imgbtn);
mUploadList = (RecyclerView) findViewById(R.id.recyclerView2);
fileNameList = new ArrayList<>();
fileDoneList = new ArrayList<>();
updateListAdapter = new UpdateListAdapter(fileNameList, fileDoneList);
mUploadList.setLayoutManager(new LinearLayoutManager(this));
mUploadList.setHasFixedSize(true);
mUploadList.setAdapter(updateListAdapter);
inipopup();
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CheckandRequestForPermission();
}
});
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
popupAddPost.show();
}
});
DrawerLayout drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
getSupportFragmentManager().beginTransaction().replace(R.id.container,new HomeFragment()).commit();
UpdateNavHeader();
}