Hello good day today was making an app connected to the database with Firebase the application is already connected and all with some tutorials that I saw on YouTube, but now I wanted to make my app more aesthetic and I added a Bottom NavigationView that will pass through different fragment by clicking on its corresponding icon, like I searched on YouTube for a tutorial to do it and it's already there, the problem is that a fragment I want to pass through, has the connection to firebase and is being inherited by AppCompatActivity and to do the bottom you need to inherit Fragment (Android.Support.v4) and then I skip error in setContentView, findViewById and getApplicationContext)
This is the code that sends me error when doing the inheritance
public class Home extends Fragment {
public RecyclerView mCategList;
private DatabaseReference mDatabase;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDatabase = FirebaseDatabase.getInstance().getReference().child("Global");
mDatabase.keepSynced(true);
mCategList = (RecyclerView) findViewById(R.id.myrecycleview);
mCategList.setHasFixedSize(true);
mCategList.setLayoutManager(new LinearLayoutManager(this));
}
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerAdapter<Categoria, categoriaViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Categoria, categoriaViewHolder>
(Categoria.class, R.layout.categ_row, categoriaViewHolder.class, mDatabase) {
@Override
protected void populateViewHolder(categoriaViewHolder viewHolder, Categoria model, int position) {
viewHolder.setTitle(model.getTitle());
viewHolder.setImage(getApplicationContext(),model.getImage());
}
};
mCategList.setAdapter(firebaseRecyclerAdapter);
}
public static class categoriaViewHolder extends RecyclerView.ViewHolder
{
View mView;
public categoriaViewHolder(View itemView)
{
super(itemView);
mView=itemView;
}
public void setTitle(String title)
{
TextView post_title=(TextView)mView.findViewById(R.id.post_title);
post_title.setText(title);
}
public void setImage(Context ctx, String image)
{
ImageView post_image=(ImageView)mView.findViewById(R.id.post_image);
Picasso.with(ctx).load(image).into(post_image);
}
}
}
When looking for the android studio tips to solve the error it just says "Can not resolve method 'findViewById (int)' And in getAplicationContext it says: "Create Getter"
If I inherit AppCompatActivity, I no longer mark an error, but I need to inherit it from Fragment in order to make the bottom