Reputation: 29
Issue: Recycler View is not displaying. There is no error logged. The page is just blank. I did attempt to look at other similar Recycler View issues, but I have not been able to figure out the problem. I played around with the layout to make sure views were not overlapping but that did not fix the issue. I also looked through the java file but cannot find anything wrong with it. Any help will be appreciated. Thank you!
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Personal_Wall"
tools:openDrawer="end">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:background="#ffff"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
elevation="4dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#ffff"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<ImageView
android:id="@+id/splashd_logo_button"
android:layout_width="120dp"
android:layout_height="60dp"
android:layout_gravity="right"
android:paddingRight="10dp"
android:src="@drawable/new_splashd_logo_black"
android:text="hapana_button" />
</androidx.appcompat.widget.Toolbar>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:overScrollMode="never"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:id="@+id/fragment-containter2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/edit_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="245dp"
android:layout_marginTop="250dp"
android:elevation="6dp"
android:background="@color/fui_transparent"
app:srcCompat="@drawable/ic_camera_icon" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_place_holder"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="95dp"
android:elevation="4dp"
android:src="@drawable/grey_oval"
app:civ_border_color="#fff"
app:civ_border_width="5dp" />
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
card_view:cardBackgroundColor="#fff"
card_view:cardCornerRadius="8dp">
<ImageView
android:id="@+id/temporary_banner_personal_wall"
android:layout_width="380dp"
android:layout_height="250dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
app:srcCompat="@drawable/roundec_corner_rectangle_grey" />
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/personal_wall_text_first_name"
android:layout_width="193dp"
android:layout_height="wrap_content"
android:layout_marginLeft="158dp"
android:layout_marginTop="310dp"
android:layout_marginRight="50dp"
android:layout_weight="0.5"
android:background="@android:color/transparent"
android:ems="10"
android:fontFamily="@font/roboto_bold"
android:inputType="textPersonName"
android:text="First"
android:textColor="#000"
android:textSize="30dp" />
<TextView
android:id="@+id/personal_wall_text_last_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="210dp"
android:layout_marginTop="310dp"
android:layout_weight="0.5"
android:background="@android:color/transparent"
android:ems="10"
android:fontFamily="@font/roboto_bold"
android:inputType="textPersonName"
android:text="Last"
android:textColor="#000"
android:textSize="30dp" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/small_grey_circle"
android:layout_width="78dp"
android:layout_height="52dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="408dp"
android:src="@drawable/small_grey_circle" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Current Location: Washington D.C."
android:textSize="18dp"
android:textColor="#000"
android:fontFamily="@font/roboto_medium"
android:layout_marginTop="360dp"
android:layout_gravity="center_horizontal"
android:drawableLeft="@drawable/ic_profile_location_on_black_24dp"
>
</TextView>
<ImageView
android:id="@+id/personal_wall_post_something_box"
android:layout_width="290dp"
android:layout_height="69dp"
android:layout_marginLeft="95dp"
android:layout_marginTop="398dp"
android:src="@drawable/make_a_splash_oval" />
<TextView
android:id="@+id/assists_count"
android:layout_width="73dp"
android:layout_height="38dp"
android:layout_marginLeft="45dp"
android:layout_marginTop="550dp"
android:layout_weight="0.5"
android:background="@android:color/transparent"
android:ems="10"
android:fontFamily="@font/roboto_light"
android:text="Assists"
android:textColor="#000"
android:textSize="15dp"
android:textAlignment="center"/>
<TextView
android:id="@+id/assists_count_actual_number"
android:layout_width="73dp"
android:layout_height="38dp"
android:layout_marginLeft="45dp"
android:layout_marginTop="515dp"
android:textAlignment="center"
android:layout_weight="0.5"
android:background="@android:color/transparent"
android:ems="10"
android:fontFamily="@font/roboto_bold"
android:text="3"
android:textColor="#000"
android:textSize="22dp" />
<TextView
android:id="@+id/followers_count"
android:layout_width="102dp"
android:layout_height="39dp"
android:layout_marginLeft="143dp"
android:layout_marginTop="550dp"
android:layout_weight="0.5"
android:background="@android:color/transparent"
android:ems="10"
android:fontFamily="@font/roboto_light"
android:text="Followers"
android:textColor="#000"
android:textSize="15dp"
android:textAlignment="center"/>
<TextView
android:id="@+id/followers_count_actual_number"
android:layout_width="102dp"
android:layout_height="39dp"
android:layout_marginLeft="144dp"
android:layout_marginTop="515dp"
android:textAlignment="center"
android:layout_weight="0.5"
android:background="@android:color/transparent"
android:ems="10"
android:fontFamily="@font/roboto_bold"
android:text="2"
android:textColor="#000"
android:textSize="22dp" />
<TextView
android:id="@+id/splash_count"
android:layout_width="102dp"
android:layout_height="39dp"
android:layout_marginLeft="250dp"
android:layout_marginTop="550dp"
android:layout_weight="0.5"
android:background="@android:color/transparent"
android:fontFamily="@font/roboto_light"
android:text="Splashes"
android:textColor="#000"
android:textSize="15dp"
android:textAlignment="center"/>
<TextView
android:id="@+id/splash_count_actual_number"
android:layout_width="102dp"
android:layout_height="39dp"
android:textAlignment="center"
android:layout_marginLeft="250dp"
android:layout_marginTop="515dp"
android:layout_weight="0.5"
android:background="@android:color/transparent"
android:ems="10"
android:fontFamily="@font/roboto_bold"
android:text="5"
android:textColor="#000"
android:textSize="22dp" />
<View
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginTop="590dp"
android:background="@android:color/darker_gray" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="488dp"
android:background="#E8E8E8" />
<TextView
android:id="@+id/testing_scrollview"
android:layout_width="102dp"
android:layout_height="39dp"
android:layout_marginLeft="293dp"
android:layout_marginTop="1400dp"
android:layout_weight="0.5"
android:fontFamily="@font/roboto_light"
android:text="TEST"
android:textColor="#000"
android:layout_marginBottom="120dp"
android:textSize="20dp"
android:textAlignment="center"/>
</FrameLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_post_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="700dp"
android:layout_above="@+id/fragment_container_3">
</androidx.recyclerview.widget.RecyclerView>
<FrameLayout
android:id="@+id/fragment_container_3"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- Main content -->
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_gravity="bottom"
android:background="?android:attr/windowBackground"
app:itemIconTint="@color/bottom_navigation_selected_color"
app:itemTextColor="@color/bottom_navigation_selected_color"
app:labelVisibilityMode="unlabeled"
app:menu="@menu/bottom_navigation_menu"
app:itemIconSize="@dimen/bottom_navigation_icon_size"
/>
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_menu" />
</androidx.drawerlayout.widget.DrawerLayout>
---------------------------------------------------------
package com.example.updatedhapana1;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.StyleSpan;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import com.squareup.picasso.Picasso;
import com.theartofdev.edmodo.cropper.CropImage;
import com.theartofdev.edmodo.cropper.CropImageView;
import de.hdodenhof.circleimageview.CircleImageView;
import static com.example.updatedhapana1.Personal_Wall_Edit.Gallery_Pick2;
public class Personal_Wall extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
Window window;
private DrawerLayout drawer;
private Bitmap bitmap;
private Uri uri;
private RecyclerView postList; //TRYING RECYCLER VIEW AGAIN AHHHHHHHHHH!
private String currentUserID;
private DatabaseReference UsersReference;
private CircleImageView profile_image;
private StorageReference UserProfileImageRef;
private FirebaseAuth mAuth;
private ImageView post_question;
private ImageButton edit_profile;
private DatabaseReference mDatabaseRef;
private ImageView banner_view;
private ImageButton splash_gallery;
FirebaseUser currentUser;
TextView mfirstname;
TextView mlastname;
TextView firstname_for_main_profile;
TextView lastname_for_main_profile;
NavigationView mNavigationView;
CircleImageView m_nav_header_profile_image;
CircleImageView profile_placeholder_personal_wall;
CircleImageView little_circle_personal_wall;
FirebaseDatabase mfirebaseDatabase;
final static int Gallery_Pick = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_personal__wall);
little_circle_personal_wall = findViewById(R.id.small_grey_circle); //this is to bring in the profile picture from the database
//////This change the status bar color and the status bar text color. I wanted the status bar to be white.//////////
if (Build.VERSION.SDK_INT > 21) {
window = this.getWindow();
window.setStatusBarColor(this.getResources().getColor(R.color.white));
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);// set status text dark
}
//////This change the status bar color and the status bar text color. I wanted the status bar to be white.//////////
mAuth = FirebaseAuth.getInstance();
currentUserID = mAuth.getCurrentUser().getUid();
UsersReference = FirebaseDatabase.getInstance().getReference().child("Users").child(currentUserID);
UserProfileImageRef = FirebaseStorage.getInstance().getReference().child("Profile Images");
profile_image = findViewById(R.id.profile_place_holder_edit);
mDatabaseRef = FirebaseDatabase.getInstance().getReference("uploads");
profile_placeholder_personal_wall = findViewById(R.id.profile_place_holder);
banner_view = findViewById(R.id.temporary_banner_personal_wall);
//RECYCLERVIEW//
postList = (RecyclerView) findViewById(R.id.recycler_view_post_list);
postList.setHasFixedSize(true);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setReverseLayout(true);
linearLayoutManager.setStackFromEnd(true);
postList.setLayoutManager(linearLayoutManager);
//RECYCLERVIEW//
----------------------------------------------------
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerOptions<Posts> options =
new FirebaseRecyclerOptions.Builder<Posts>()
.setQuery(UsersReference, Posts.class)
.build();
FirebaseRecyclerAdapter<Posts,FindPostsViewHolder> adapter =
new FirebaseRecyclerAdapter<Posts, FindPostsViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull FindPostsViewHolder findPostsViewHolder, int i, @NonNull Posts posts)
{
findPostsViewHolder.first_name.setText(posts.getFirst_name());
findPostsViewHolder.last_name.setText(posts.getLast_name());
findPostsViewHolder.post_date.setText(posts.getPost_date());
findPostsViewHolder.post_body_text.setText(posts.getPost_body_text());
}
@NonNull
@Override
public FindPostsViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.post_layout_2, viewGroup, false);
FindPostsViewHolder viewHolder = new FindPostsViewHolder(view);
return viewHolder;
}
};
postList.setAdapter(adapter);
adapter.startListening();
}
public static class FindPostsViewHolder extends RecyclerView.ViewHolder
{
TextView first_name, last_name, post_body_text, post_date;
public FindPostsViewHolder(@NonNull View itemView)
{
super(itemView);
first_name = itemView.findViewById(R.id.post_first_name);
last_name = itemView.findViewById(R.id.post_last_name);
post_date = itemView.findViewById(R.id.post_date_and_time);
post_body_text = itemView.findViewById(R.id.the_post);
}
}
----------------------------------------------
package com.example.updatedhapana1;
public class Posts
{
public String first_name, last_name, post_body_text, post_date;
//this is an empty contstructor- this is required//
public Posts ()
{
}
//this is an empty contstructor- this is required//
public Posts(String first_name, String last_name, String post_body_text, String post_date) {
this.first_name = first_name;
this.last_name = last_name;
this.post_body_text = post_body_text;
this.post_date = post_date;
}
public String getFirst_name() {
return first_name;
}
public void setFirst_name(String first_name) {
this.first_name = first_name;
}
public String getLast_name() {
return last_name;
}
public void setLast_name(String last_name) {
this.last_name = last_name;
}
public String getPost_body_text() {
return post_body_text;
}
public void setPost_body_text(String post_body_text) {
this.post_body_text = post_body_text;
}
public String getPost_date() {
return post_date;
}
public void setPost_date(String post_date) {
this.post_date = post_date;
}
}
Upvotes: 0
Views: 207
Reputation: 29
Edit I figured out my issue. My recycler view items were not displaying because of how my data was structured in firebase. Thank you everyone for your help.
Upvotes: 0
Reputation: 830
Remove this from your Recyclerview: android:layout_marginTop="700dp""
.
It has set the top margin 700dp which makes it go out of the screen.
Upvotes: 0
Reputation: 319
I think it's your last FrameLayout where is height is match_parent and is overlapping everything. If it's not this layout try to replace others layout by wrap_content or when your run your app, you have "layout inspector" in Android Studio and you can find your error.
Upvotes: 0
Reputation: 643
I haven't tested your code, but this is what I suspect. From your XML it seems like you have linear layout and recycler view in 2 separate components and your LinearLayout is match_parent. So I am assuming it's taking the entire space.
Upvotes: 1