RecyclerView problems












0














I've got a problem, i have a recyclerview wich displays firebase-firestore data into cardviews. All is working :https://drive.google.com/file/d/1_IE9afCX3A4lPZn_VLRpBV4YtC-9XMWd/view?usp=sharing, https://drive.google.com/file/d/10sYU6v4Wb94gbKvuOuNf8-hsGpkNJatZ/view?usp=sharing



But when i'm adding my BottomNavigationBar in my Planning layout, a very strange problem is happening : https://drive.google.com/open?id=1SOCTsqLCcQdD431MdBWY5zZo5mUzPxG2, https://drive.google.com/open?id=1-xRlPsvuADNYEB9kHqAz45txiwnkR8x_



Can someone help me to fix this problem please ? <3



Here's my Planning.xml :



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
xmlns:app="http://schemas.android.com/apk/res-auto">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>

<android.support.design.widget.BottomNavigationView
android:id="@+id/mainNav"
android:layout_width="match_parent"
android:layout_height="56dp"
app:itemBackground="@color/colorPrimary"
app:itemTextColor="@color/white"
app:itemIconTint="@color/white"
app:menu="@menu/nav_items">
</android.support.design.widget.BottomNavigationView>

</LinearLayout>


List_menu.xml :



<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="10dp"
app:cardCornerRadius="10dp"
android:elevation="10dp"
android:id="@+id/cardView"
xmlns:tools="http://schemas.android.com/tools">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:orientation="vertical">

<TextView
android:id="@+id/nom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:fontFamily="sans-serif-condensed"
android:textSize="20sp"/>

<TextView
android:id="@+id/lieu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"/>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:fontFamily="sans-serif-condensed"/>

</LinearLayout>

</RelativeLayout>
</android.support.v7.widget.CardView>


Planning.java :



public class Planning extends AppCompatActivity {

FirebaseFirestore db = FirebaseFirestore.getInstance();
RecyclerView recyclerView;
ArrayList<Events> eventsArrayList;
MyRecyclerViewAdapter adapter;
BottomNavigationView mainNav;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_planning);
mainNav = (BottomNavigationView)findViewById(R.id.mainNav);
eventsArrayList = new ArrayList<>();
setUpBottomNav();
setUpRecyclerView();
setUpFirebase();
loadDataFromFirebase();
}

private void setUpRecyclerView(){
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}

private void setUpFirebase(){
db = FirebaseFirestore.getInstance();
}

private void loadDataFromFirebase(){
if(eventsArrayList.size()>0){
eventsArrayList.clear();}
db.collection("Planning").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
for(DocumentSnapshot querySnapshot: task.getResult()){
Events Nom = new Events(querySnapshot.getString("Nom"),querySnapshot.getString("Lieu"),querySnapshot.getString("Date"));
eventsArrayList.add(Nom);
}
adapter = new MyRecyclerViewAdapter(Planning.this, eventsArrayList);
recyclerView.setAdapter(adapter);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Planning.this, "Erreur(s) :", Toast.LENGTH_SHORT).show();
Log.v("---]---", e.getMessage());
}
});
}

private void setUpBottomNav(){
mainNav.getMenu().getItem(3).setChecked(true);
mainNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()){
case R.id.nav_home :
Intent intent = new Intent(Planning.this, Home.class);
startActivity(intent);
return true;
case R.id.nav_map :
Intent intent2 = new Intent(Planning.this, Localisation.class);
startActivity(intent2);
return true;
case R.id.nav_search :
Intent intent3 = new Intent(Planning.this, Search.class);
startActivity(intent3);
return true;
case R.id.nav_planning :
return true;
case R.id.nav_contact :
Intent intent4 = new Intent(Planning.this, Contact.class);
startActivity(intent4);
return true;
default:
return false;
}
}
});
}
}


MyRecyclerViewHolder.java :



public class MyRecyclerViewHolder extends RecyclerView.ViewHolder {

public TextView tvNom, tvLieu, tvDate;
public CardView cardView;

public MyRecyclerViewHolder(View itemView){
super(itemView);
cardView = itemView.findViewById(R.id.cardView);
tvNom = itemView.findViewById(R.id.nom);
tvLieu = itemView.findViewById(R.id.lieu);
tvDate = itemView.findViewById(R.id.date);
}
}


MyRecyclerViewAdapter.java :



public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewHolder> {

Planning planning;
ArrayList<Events> eventsArrayList;

public MyRecyclerViewAdapter(Planning planning, ArrayList<Events> eventsArrayList) {
this.planning = planning;
this.eventsArrayList = eventsArrayList;
}

@NonNull
@Override
public MyRecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {

LayoutInflater layoutInflater = LayoutInflater.from(planning.getBaseContext());
View view = layoutInflater.inflate(R.layout.list_item, viewGroup, false);
return new MyRecyclerViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull MyRecyclerViewHolder holder, int position) {
holder.tvNom.setText(eventsArrayList.get(position).getNom());
holder.tvLieu.setText(eventsArrayList.get(position).getLieu());
if(eventsArrayList.get(position).getLieu() == ""){ holder.tvLieu.setVisibility(View.GONE);}
if(eventsArrayList.get(position).getDate() == ""){ holder.tvDate.setVisibility(View.GONE);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) holder.tvNom.getLayoutParams();
params.gravity = Gravity.CENTER;
holder.tvNom.setLayoutParams(params);
holder.cardView.setCardBackgroundColor(Color.GRAY);
}else{holder.tvDate.setText(eventsArrayList.get(position).getDate());}
}

@Override
public int getItemCount() {
return eventsArrayList.size();
}
}


Events.java :



public class Events {

String Nom;
String Lieu;
String Date;

public Events(String Nom, String Lieu, String Date){
this.Nom = Nom;
this.Lieu = Lieu;
this.Date = Date;
}

public String getNom() {
return Nom;
}

public void setNom(String nom) {
Nom = nom;
}

public String getLieu() {
return Lieu;
}

public void setLieu(String lieu) {
Lieu = lieu;
}

public String getDate() {
return Date;
}

public void setDate(String date) {
Date = date;
}
}









share|improve this question






















  • If you encounter problems, it's best to create a MCVE when posting a question. You posted almost 250 lines of code for this issue. That's a lot for people to parse and try to debug online.
    – Alex Mamo
    Nov 13 at 16:16
















0














I've got a problem, i have a recyclerview wich displays firebase-firestore data into cardviews. All is working :https://drive.google.com/file/d/1_IE9afCX3A4lPZn_VLRpBV4YtC-9XMWd/view?usp=sharing, https://drive.google.com/file/d/10sYU6v4Wb94gbKvuOuNf8-hsGpkNJatZ/view?usp=sharing



But when i'm adding my BottomNavigationBar in my Planning layout, a very strange problem is happening : https://drive.google.com/open?id=1SOCTsqLCcQdD431MdBWY5zZo5mUzPxG2, https://drive.google.com/open?id=1-xRlPsvuADNYEB9kHqAz45txiwnkR8x_



Can someone help me to fix this problem please ? <3



Here's my Planning.xml :



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
xmlns:app="http://schemas.android.com/apk/res-auto">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>

<android.support.design.widget.BottomNavigationView
android:id="@+id/mainNav"
android:layout_width="match_parent"
android:layout_height="56dp"
app:itemBackground="@color/colorPrimary"
app:itemTextColor="@color/white"
app:itemIconTint="@color/white"
app:menu="@menu/nav_items">
</android.support.design.widget.BottomNavigationView>

</LinearLayout>


List_menu.xml :



<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="10dp"
app:cardCornerRadius="10dp"
android:elevation="10dp"
android:id="@+id/cardView"
xmlns:tools="http://schemas.android.com/tools">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:orientation="vertical">

<TextView
android:id="@+id/nom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:fontFamily="sans-serif-condensed"
android:textSize="20sp"/>

<TextView
android:id="@+id/lieu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"/>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:fontFamily="sans-serif-condensed"/>

</LinearLayout>

</RelativeLayout>
</android.support.v7.widget.CardView>


Planning.java :



public class Planning extends AppCompatActivity {

FirebaseFirestore db = FirebaseFirestore.getInstance();
RecyclerView recyclerView;
ArrayList<Events> eventsArrayList;
MyRecyclerViewAdapter adapter;
BottomNavigationView mainNav;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_planning);
mainNav = (BottomNavigationView)findViewById(R.id.mainNav);
eventsArrayList = new ArrayList<>();
setUpBottomNav();
setUpRecyclerView();
setUpFirebase();
loadDataFromFirebase();
}

private void setUpRecyclerView(){
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}

private void setUpFirebase(){
db = FirebaseFirestore.getInstance();
}

private void loadDataFromFirebase(){
if(eventsArrayList.size()>0){
eventsArrayList.clear();}
db.collection("Planning").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
for(DocumentSnapshot querySnapshot: task.getResult()){
Events Nom = new Events(querySnapshot.getString("Nom"),querySnapshot.getString("Lieu"),querySnapshot.getString("Date"));
eventsArrayList.add(Nom);
}
adapter = new MyRecyclerViewAdapter(Planning.this, eventsArrayList);
recyclerView.setAdapter(adapter);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Planning.this, "Erreur(s) :", Toast.LENGTH_SHORT).show();
Log.v("---]---", e.getMessage());
}
});
}

private void setUpBottomNav(){
mainNav.getMenu().getItem(3).setChecked(true);
mainNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()){
case R.id.nav_home :
Intent intent = new Intent(Planning.this, Home.class);
startActivity(intent);
return true;
case R.id.nav_map :
Intent intent2 = new Intent(Planning.this, Localisation.class);
startActivity(intent2);
return true;
case R.id.nav_search :
Intent intent3 = new Intent(Planning.this, Search.class);
startActivity(intent3);
return true;
case R.id.nav_planning :
return true;
case R.id.nav_contact :
Intent intent4 = new Intent(Planning.this, Contact.class);
startActivity(intent4);
return true;
default:
return false;
}
}
});
}
}


MyRecyclerViewHolder.java :



public class MyRecyclerViewHolder extends RecyclerView.ViewHolder {

public TextView tvNom, tvLieu, tvDate;
public CardView cardView;

public MyRecyclerViewHolder(View itemView){
super(itemView);
cardView = itemView.findViewById(R.id.cardView);
tvNom = itemView.findViewById(R.id.nom);
tvLieu = itemView.findViewById(R.id.lieu);
tvDate = itemView.findViewById(R.id.date);
}
}


MyRecyclerViewAdapter.java :



public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewHolder> {

Planning planning;
ArrayList<Events> eventsArrayList;

public MyRecyclerViewAdapter(Planning planning, ArrayList<Events> eventsArrayList) {
this.planning = planning;
this.eventsArrayList = eventsArrayList;
}

@NonNull
@Override
public MyRecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {

LayoutInflater layoutInflater = LayoutInflater.from(planning.getBaseContext());
View view = layoutInflater.inflate(R.layout.list_item, viewGroup, false);
return new MyRecyclerViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull MyRecyclerViewHolder holder, int position) {
holder.tvNom.setText(eventsArrayList.get(position).getNom());
holder.tvLieu.setText(eventsArrayList.get(position).getLieu());
if(eventsArrayList.get(position).getLieu() == ""){ holder.tvLieu.setVisibility(View.GONE);}
if(eventsArrayList.get(position).getDate() == ""){ holder.tvDate.setVisibility(View.GONE);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) holder.tvNom.getLayoutParams();
params.gravity = Gravity.CENTER;
holder.tvNom.setLayoutParams(params);
holder.cardView.setCardBackgroundColor(Color.GRAY);
}else{holder.tvDate.setText(eventsArrayList.get(position).getDate());}
}

@Override
public int getItemCount() {
return eventsArrayList.size();
}
}


Events.java :



public class Events {

String Nom;
String Lieu;
String Date;

public Events(String Nom, String Lieu, String Date){
this.Nom = Nom;
this.Lieu = Lieu;
this.Date = Date;
}

public String getNom() {
return Nom;
}

public void setNom(String nom) {
Nom = nom;
}

public String getLieu() {
return Lieu;
}

public void setLieu(String lieu) {
Lieu = lieu;
}

public String getDate() {
return Date;
}

public void setDate(String date) {
Date = date;
}
}









share|improve this question






















  • If you encounter problems, it's best to create a MCVE when posting a question. You posted almost 250 lines of code for this issue. That's a lot for people to parse and try to debug online.
    – Alex Mamo
    Nov 13 at 16:16














0












0








0







I've got a problem, i have a recyclerview wich displays firebase-firestore data into cardviews. All is working :https://drive.google.com/file/d/1_IE9afCX3A4lPZn_VLRpBV4YtC-9XMWd/view?usp=sharing, https://drive.google.com/file/d/10sYU6v4Wb94gbKvuOuNf8-hsGpkNJatZ/view?usp=sharing



But when i'm adding my BottomNavigationBar in my Planning layout, a very strange problem is happening : https://drive.google.com/open?id=1SOCTsqLCcQdD431MdBWY5zZo5mUzPxG2, https://drive.google.com/open?id=1-xRlPsvuADNYEB9kHqAz45txiwnkR8x_



Can someone help me to fix this problem please ? <3



Here's my Planning.xml :



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
xmlns:app="http://schemas.android.com/apk/res-auto">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>

<android.support.design.widget.BottomNavigationView
android:id="@+id/mainNav"
android:layout_width="match_parent"
android:layout_height="56dp"
app:itemBackground="@color/colorPrimary"
app:itemTextColor="@color/white"
app:itemIconTint="@color/white"
app:menu="@menu/nav_items">
</android.support.design.widget.BottomNavigationView>

</LinearLayout>


List_menu.xml :



<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="10dp"
app:cardCornerRadius="10dp"
android:elevation="10dp"
android:id="@+id/cardView"
xmlns:tools="http://schemas.android.com/tools">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:orientation="vertical">

<TextView
android:id="@+id/nom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:fontFamily="sans-serif-condensed"
android:textSize="20sp"/>

<TextView
android:id="@+id/lieu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"/>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:fontFamily="sans-serif-condensed"/>

</LinearLayout>

</RelativeLayout>
</android.support.v7.widget.CardView>


Planning.java :



public class Planning extends AppCompatActivity {

FirebaseFirestore db = FirebaseFirestore.getInstance();
RecyclerView recyclerView;
ArrayList<Events> eventsArrayList;
MyRecyclerViewAdapter adapter;
BottomNavigationView mainNav;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_planning);
mainNav = (BottomNavigationView)findViewById(R.id.mainNav);
eventsArrayList = new ArrayList<>();
setUpBottomNav();
setUpRecyclerView();
setUpFirebase();
loadDataFromFirebase();
}

private void setUpRecyclerView(){
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}

private void setUpFirebase(){
db = FirebaseFirestore.getInstance();
}

private void loadDataFromFirebase(){
if(eventsArrayList.size()>0){
eventsArrayList.clear();}
db.collection("Planning").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
for(DocumentSnapshot querySnapshot: task.getResult()){
Events Nom = new Events(querySnapshot.getString("Nom"),querySnapshot.getString("Lieu"),querySnapshot.getString("Date"));
eventsArrayList.add(Nom);
}
adapter = new MyRecyclerViewAdapter(Planning.this, eventsArrayList);
recyclerView.setAdapter(adapter);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Planning.this, "Erreur(s) :", Toast.LENGTH_SHORT).show();
Log.v("---]---", e.getMessage());
}
});
}

private void setUpBottomNav(){
mainNav.getMenu().getItem(3).setChecked(true);
mainNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()){
case R.id.nav_home :
Intent intent = new Intent(Planning.this, Home.class);
startActivity(intent);
return true;
case R.id.nav_map :
Intent intent2 = new Intent(Planning.this, Localisation.class);
startActivity(intent2);
return true;
case R.id.nav_search :
Intent intent3 = new Intent(Planning.this, Search.class);
startActivity(intent3);
return true;
case R.id.nav_planning :
return true;
case R.id.nav_contact :
Intent intent4 = new Intent(Planning.this, Contact.class);
startActivity(intent4);
return true;
default:
return false;
}
}
});
}
}


MyRecyclerViewHolder.java :



public class MyRecyclerViewHolder extends RecyclerView.ViewHolder {

public TextView tvNom, tvLieu, tvDate;
public CardView cardView;

public MyRecyclerViewHolder(View itemView){
super(itemView);
cardView = itemView.findViewById(R.id.cardView);
tvNom = itemView.findViewById(R.id.nom);
tvLieu = itemView.findViewById(R.id.lieu);
tvDate = itemView.findViewById(R.id.date);
}
}


MyRecyclerViewAdapter.java :



public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewHolder> {

Planning planning;
ArrayList<Events> eventsArrayList;

public MyRecyclerViewAdapter(Planning planning, ArrayList<Events> eventsArrayList) {
this.planning = planning;
this.eventsArrayList = eventsArrayList;
}

@NonNull
@Override
public MyRecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {

LayoutInflater layoutInflater = LayoutInflater.from(planning.getBaseContext());
View view = layoutInflater.inflate(R.layout.list_item, viewGroup, false);
return new MyRecyclerViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull MyRecyclerViewHolder holder, int position) {
holder.tvNom.setText(eventsArrayList.get(position).getNom());
holder.tvLieu.setText(eventsArrayList.get(position).getLieu());
if(eventsArrayList.get(position).getLieu() == ""){ holder.tvLieu.setVisibility(View.GONE);}
if(eventsArrayList.get(position).getDate() == ""){ holder.tvDate.setVisibility(View.GONE);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) holder.tvNom.getLayoutParams();
params.gravity = Gravity.CENTER;
holder.tvNom.setLayoutParams(params);
holder.cardView.setCardBackgroundColor(Color.GRAY);
}else{holder.tvDate.setText(eventsArrayList.get(position).getDate());}
}

@Override
public int getItemCount() {
return eventsArrayList.size();
}
}


Events.java :



public class Events {

String Nom;
String Lieu;
String Date;

public Events(String Nom, String Lieu, String Date){
this.Nom = Nom;
this.Lieu = Lieu;
this.Date = Date;
}

public String getNom() {
return Nom;
}

public void setNom(String nom) {
Nom = nom;
}

public String getLieu() {
return Lieu;
}

public void setLieu(String lieu) {
Lieu = lieu;
}

public String getDate() {
return Date;
}

public void setDate(String date) {
Date = date;
}
}









share|improve this question













I've got a problem, i have a recyclerview wich displays firebase-firestore data into cardviews. All is working :https://drive.google.com/file/d/1_IE9afCX3A4lPZn_VLRpBV4YtC-9XMWd/view?usp=sharing, https://drive.google.com/file/d/10sYU6v4Wb94gbKvuOuNf8-hsGpkNJatZ/view?usp=sharing



But when i'm adding my BottomNavigationBar in my Planning layout, a very strange problem is happening : https://drive.google.com/open?id=1SOCTsqLCcQdD431MdBWY5zZo5mUzPxG2, https://drive.google.com/open?id=1-xRlPsvuADNYEB9kHqAz45txiwnkR8x_



Can someone help me to fix this problem please ? <3



Here's my Planning.xml :



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
xmlns:app="http://schemas.android.com/apk/res-auto">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>

<android.support.design.widget.BottomNavigationView
android:id="@+id/mainNav"
android:layout_width="match_parent"
android:layout_height="56dp"
app:itemBackground="@color/colorPrimary"
app:itemTextColor="@color/white"
app:itemIconTint="@color/white"
app:menu="@menu/nav_items">
</android.support.design.widget.BottomNavigationView>

</LinearLayout>


List_menu.xml :



<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="10dp"
app:cardCornerRadius="10dp"
android:elevation="10dp"
android:id="@+id/cardView"
xmlns:tools="http://schemas.android.com/tools">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:orientation="vertical">

<TextView
android:id="@+id/nom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:fontFamily="sans-serif-condensed"
android:textSize="20sp"/>

<TextView
android:id="@+id/lieu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"/>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:fontFamily="sans-serif-condensed"/>

</LinearLayout>

</RelativeLayout>
</android.support.v7.widget.CardView>


Planning.java :



public class Planning extends AppCompatActivity {

FirebaseFirestore db = FirebaseFirestore.getInstance();
RecyclerView recyclerView;
ArrayList<Events> eventsArrayList;
MyRecyclerViewAdapter adapter;
BottomNavigationView mainNav;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_planning);
mainNav = (BottomNavigationView)findViewById(R.id.mainNav);
eventsArrayList = new ArrayList<>();
setUpBottomNav();
setUpRecyclerView();
setUpFirebase();
loadDataFromFirebase();
}

private void setUpRecyclerView(){
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}

private void setUpFirebase(){
db = FirebaseFirestore.getInstance();
}

private void loadDataFromFirebase(){
if(eventsArrayList.size()>0){
eventsArrayList.clear();}
db.collection("Planning").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
for(DocumentSnapshot querySnapshot: task.getResult()){
Events Nom = new Events(querySnapshot.getString("Nom"),querySnapshot.getString("Lieu"),querySnapshot.getString("Date"));
eventsArrayList.add(Nom);
}
adapter = new MyRecyclerViewAdapter(Planning.this, eventsArrayList);
recyclerView.setAdapter(adapter);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Planning.this, "Erreur(s) :", Toast.LENGTH_SHORT).show();
Log.v("---]---", e.getMessage());
}
});
}

private void setUpBottomNav(){
mainNav.getMenu().getItem(3).setChecked(true);
mainNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()){
case R.id.nav_home :
Intent intent = new Intent(Planning.this, Home.class);
startActivity(intent);
return true;
case R.id.nav_map :
Intent intent2 = new Intent(Planning.this, Localisation.class);
startActivity(intent2);
return true;
case R.id.nav_search :
Intent intent3 = new Intent(Planning.this, Search.class);
startActivity(intent3);
return true;
case R.id.nav_planning :
return true;
case R.id.nav_contact :
Intent intent4 = new Intent(Planning.this, Contact.class);
startActivity(intent4);
return true;
default:
return false;
}
}
});
}
}


MyRecyclerViewHolder.java :



public class MyRecyclerViewHolder extends RecyclerView.ViewHolder {

public TextView tvNom, tvLieu, tvDate;
public CardView cardView;

public MyRecyclerViewHolder(View itemView){
super(itemView);
cardView = itemView.findViewById(R.id.cardView);
tvNom = itemView.findViewById(R.id.nom);
tvLieu = itemView.findViewById(R.id.lieu);
tvDate = itemView.findViewById(R.id.date);
}
}


MyRecyclerViewAdapter.java :



public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewHolder> {

Planning planning;
ArrayList<Events> eventsArrayList;

public MyRecyclerViewAdapter(Planning planning, ArrayList<Events> eventsArrayList) {
this.planning = planning;
this.eventsArrayList = eventsArrayList;
}

@NonNull
@Override
public MyRecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {

LayoutInflater layoutInflater = LayoutInflater.from(planning.getBaseContext());
View view = layoutInflater.inflate(R.layout.list_item, viewGroup, false);
return new MyRecyclerViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull MyRecyclerViewHolder holder, int position) {
holder.tvNom.setText(eventsArrayList.get(position).getNom());
holder.tvLieu.setText(eventsArrayList.get(position).getLieu());
if(eventsArrayList.get(position).getLieu() == ""){ holder.tvLieu.setVisibility(View.GONE);}
if(eventsArrayList.get(position).getDate() == ""){ holder.tvDate.setVisibility(View.GONE);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) holder.tvNom.getLayoutParams();
params.gravity = Gravity.CENTER;
holder.tvNom.setLayoutParams(params);
holder.cardView.setCardBackgroundColor(Color.GRAY);
}else{holder.tvDate.setText(eventsArrayList.get(position).getDate());}
}

@Override
public int getItemCount() {
return eventsArrayList.size();
}
}


Events.java :



public class Events {

String Nom;
String Lieu;
String Date;

public Events(String Nom, String Lieu, String Date){
this.Nom = Nom;
this.Lieu = Lieu;
this.Date = Date;
}

public String getNom() {
return Nom;
}

public void setNom(String nom) {
Nom = nom;
}

public String getLieu() {
return Lieu;
}

public void setLieu(String lieu) {
Lieu = lieu;
}

public String getDate() {
return Date;
}

public void setDate(String date) {
Date = date;
}
}






android firebase layout android-recyclerview android-cardview






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 at 14:41







user9545141



















  • If you encounter problems, it's best to create a MCVE when posting a question. You posted almost 250 lines of code for this issue. That's a lot for people to parse and try to debug online.
    – Alex Mamo
    Nov 13 at 16:16


















  • If you encounter problems, it's best to create a MCVE when posting a question. You posted almost 250 lines of code for this issue. That's a lot for people to parse and try to debug online.
    – Alex Mamo
    Nov 13 at 16:16
















If you encounter problems, it's best to create a MCVE when posting a question. You posted almost 250 lines of code for this issue. That's a lot for people to parse and try to debug online.
– Alex Mamo
Nov 13 at 16:16




If you encounter problems, it's best to create a MCVE when posting a question. You posted almost 250 lines of code for this issue. That's a lot for people to parse and try to debug online.
– Alex Mamo
Nov 13 at 16:16












1 Answer
1






active

oldest

votes


















0














set recyclerview in fragment and replace it with framelayout
which is a container with recyclerview fragment and inflate this fragment when click on bottom sheet button






share|improve this answer





















  • How to do it exactly ? I'm beginer in android dev
    – user9545141
    Nov 13 at 15:12











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283464%2frecyclerview-problems%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown
























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














set recyclerview in fragment and replace it with framelayout
which is a container with recyclerview fragment and inflate this fragment when click on bottom sheet button






share|improve this answer





















  • How to do it exactly ? I'm beginer in android dev
    – user9545141
    Nov 13 at 15:12
















0














set recyclerview in fragment and replace it with framelayout
which is a container with recyclerview fragment and inflate this fragment when click on bottom sheet button






share|improve this answer





















  • How to do it exactly ? I'm beginer in android dev
    – user9545141
    Nov 13 at 15:12














0












0








0






set recyclerview in fragment and replace it with framelayout
which is a container with recyclerview fragment and inflate this fragment when click on bottom sheet button






share|improve this answer












set recyclerview in fragment and replace it with framelayout
which is a container with recyclerview fragment and inflate this fragment when click on bottom sheet button







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 at 15:00









mina shaker

12




12












  • How to do it exactly ? I'm beginer in android dev
    – user9545141
    Nov 13 at 15:12


















  • How to do it exactly ? I'm beginer in android dev
    – user9545141
    Nov 13 at 15:12
















How to do it exactly ? I'm beginer in android dev
– user9545141
Nov 13 at 15:12




How to do it exactly ? I'm beginer in android dev
– user9545141
Nov 13 at 15:12


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283464%2frecyclerview-problems%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)