E/RecyclerView: No adapter attached; skipping layout NEW
I have looked at many solutions and have made adjustments based on feedback from a previous version of the code I had but i still cant seem to get it to work and have the same error
JudgeActivty:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_judge);
RecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerView.setHasFixedSize(true);
RecyclerView.setLayoutManager(new LinearLayoutManager(this));
ProgressCircle = findViewById(R.id.progress_circle);
mUploads = new ArrayList<>();
DatabaseRef = FirebaseDatabase.getInstance().getReference("uploads");
DatabaseRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
UploadClass upload =
postSnapshot.getValue(UploadClass.class);
mUploads.add(upload);
}
Adapter = new ImageAdapter(JudgeActivity.this, mUploads);
ProgressCircle.setVisibility(View.INVISIBLE);
RecyclerView.setAdapter(Adapter);
}
});
}
Adapter:
public class ImageAdapter extends
RecyclerView.Adapter<ImageAdapter.ImageViewHolder> {
private Context mContext;
private List<UploadClass> mUploads;
public ImageAdapter(Context context, List<UploadClass> uploads) {
mContext = context;
mUploads = uploads;
}
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(mContext).inflate(R.layout.image_item,
parent, false);
return new ImageViewHolder(v);
}
@Override
public void onBindViewHolder(ImageViewHolder holder, int position) {
UploadClass uploadCurrent = mUploads.get(position);
holder.textViewName.setText(uploadCurrent.getName());
Picasso.with(mContext)
.load(uploadCurrent.getImageUrl())
.placeholder(R.mipmap.ic_launcher)
.fit()
.centerCrop()
.into(holder.imageView);
}
@Override
public int getItemCount() {
return mUploads.size();
}
public class ImageViewHolder extends RecyclerView.ViewHolder {
public TextView textViewName;
public ImageView imageView;
public ImageViewHolder(View itemView) {
super(itemView);
textViewName = itemView.findViewById(R.id.text_view_name);
imageView = itemView.findViewById(R.id.image_view_upload);
}
}
}
java android android-recyclerview
add a comment |
I have looked at many solutions and have made adjustments based on feedback from a previous version of the code I had but i still cant seem to get it to work and have the same error
JudgeActivty:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_judge);
RecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerView.setHasFixedSize(true);
RecyclerView.setLayoutManager(new LinearLayoutManager(this));
ProgressCircle = findViewById(R.id.progress_circle);
mUploads = new ArrayList<>();
DatabaseRef = FirebaseDatabase.getInstance().getReference("uploads");
DatabaseRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
UploadClass upload =
postSnapshot.getValue(UploadClass.class);
mUploads.add(upload);
}
Adapter = new ImageAdapter(JudgeActivity.this, mUploads);
ProgressCircle.setVisibility(View.INVISIBLE);
RecyclerView.setAdapter(Adapter);
}
});
}
Adapter:
public class ImageAdapter extends
RecyclerView.Adapter<ImageAdapter.ImageViewHolder> {
private Context mContext;
private List<UploadClass> mUploads;
public ImageAdapter(Context context, List<UploadClass> uploads) {
mContext = context;
mUploads = uploads;
}
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(mContext).inflate(R.layout.image_item,
parent, false);
return new ImageViewHolder(v);
}
@Override
public void onBindViewHolder(ImageViewHolder holder, int position) {
UploadClass uploadCurrent = mUploads.get(position);
holder.textViewName.setText(uploadCurrent.getName());
Picasso.with(mContext)
.load(uploadCurrent.getImageUrl())
.placeholder(R.mipmap.ic_launcher)
.fit()
.centerCrop()
.into(holder.imageView);
}
@Override
public int getItemCount() {
return mUploads.size();
}
public class ImageViewHolder extends RecyclerView.ViewHolder {
public TextView textViewName;
public ImageView imageView;
public ImageViewHolder(View itemView) {
super(itemView);
textViewName = itemView.findViewById(R.id.text_view_name);
imageView = itemView.findViewById(R.id.image_view_upload);
}
}
}
java android android-recyclerview
please show your code
– Badran
Nov 13 '18 at 17:36
add a comment |
I have looked at many solutions and have made adjustments based on feedback from a previous version of the code I had but i still cant seem to get it to work and have the same error
JudgeActivty:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_judge);
RecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerView.setHasFixedSize(true);
RecyclerView.setLayoutManager(new LinearLayoutManager(this));
ProgressCircle = findViewById(R.id.progress_circle);
mUploads = new ArrayList<>();
DatabaseRef = FirebaseDatabase.getInstance().getReference("uploads");
DatabaseRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
UploadClass upload =
postSnapshot.getValue(UploadClass.class);
mUploads.add(upload);
}
Adapter = new ImageAdapter(JudgeActivity.this, mUploads);
ProgressCircle.setVisibility(View.INVISIBLE);
RecyclerView.setAdapter(Adapter);
}
});
}
Adapter:
public class ImageAdapter extends
RecyclerView.Adapter<ImageAdapter.ImageViewHolder> {
private Context mContext;
private List<UploadClass> mUploads;
public ImageAdapter(Context context, List<UploadClass> uploads) {
mContext = context;
mUploads = uploads;
}
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(mContext).inflate(R.layout.image_item,
parent, false);
return new ImageViewHolder(v);
}
@Override
public void onBindViewHolder(ImageViewHolder holder, int position) {
UploadClass uploadCurrent = mUploads.get(position);
holder.textViewName.setText(uploadCurrent.getName());
Picasso.with(mContext)
.load(uploadCurrent.getImageUrl())
.placeholder(R.mipmap.ic_launcher)
.fit()
.centerCrop()
.into(holder.imageView);
}
@Override
public int getItemCount() {
return mUploads.size();
}
public class ImageViewHolder extends RecyclerView.ViewHolder {
public TextView textViewName;
public ImageView imageView;
public ImageViewHolder(View itemView) {
super(itemView);
textViewName = itemView.findViewById(R.id.text_view_name);
imageView = itemView.findViewById(R.id.image_view_upload);
}
}
}
java android android-recyclerview
I have looked at many solutions and have made adjustments based on feedback from a previous version of the code I had but i still cant seem to get it to work and have the same error
JudgeActivty:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_judge);
RecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerView.setHasFixedSize(true);
RecyclerView.setLayoutManager(new LinearLayoutManager(this));
ProgressCircle = findViewById(R.id.progress_circle);
mUploads = new ArrayList<>();
DatabaseRef = FirebaseDatabase.getInstance().getReference("uploads");
DatabaseRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
UploadClass upload =
postSnapshot.getValue(UploadClass.class);
mUploads.add(upload);
}
Adapter = new ImageAdapter(JudgeActivity.this, mUploads);
ProgressCircle.setVisibility(View.INVISIBLE);
RecyclerView.setAdapter(Adapter);
}
});
}
Adapter:
public class ImageAdapter extends
RecyclerView.Adapter<ImageAdapter.ImageViewHolder> {
private Context mContext;
private List<UploadClass> mUploads;
public ImageAdapter(Context context, List<UploadClass> uploads) {
mContext = context;
mUploads = uploads;
}
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(mContext).inflate(R.layout.image_item,
parent, false);
return new ImageViewHolder(v);
}
@Override
public void onBindViewHolder(ImageViewHolder holder, int position) {
UploadClass uploadCurrent = mUploads.get(position);
holder.textViewName.setText(uploadCurrent.getName());
Picasso.with(mContext)
.load(uploadCurrent.getImageUrl())
.placeholder(R.mipmap.ic_launcher)
.fit()
.centerCrop()
.into(holder.imageView);
}
@Override
public int getItemCount() {
return mUploads.size();
}
public class ImageViewHolder extends RecyclerView.ViewHolder {
public TextView textViewName;
public ImageView imageView;
public ImageViewHolder(View itemView) {
super(itemView);
textViewName = itemView.findViewById(R.id.text_view_name);
imageView = itemView.findViewById(R.id.image_view_upload);
}
}
}
java android android-recyclerview
java android android-recyclerview
edited Nov 13 '18 at 17:39
TheWanderer
6,96221028
6,96221028
asked Nov 13 '18 at 17:29
A.FitzgeraldA.Fitzgerald
114
114
please show your code
– Badran
Nov 13 '18 at 17:36
add a comment |
please show your code
– Badran
Nov 13 '18 at 17:36
please show your code
– Badran
Nov 13 '18 at 17:36
please show your code
– Badran
Nov 13 '18 at 17:36
add a comment |
1 Answer
1
active
oldest
votes
Is there actually a problem? That "error" isn't an error, it's just a warning. And it's shown because, when the Activity is first displayed, the RecyclerView has no Adapter set to it. You only set the Adapter when a Firebase value changes, which is a bad idea.
You should create and set the Adapter outside of the ValueEventListener:
RecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerView.setHasFixedSize(true);
RecyclerView.setLayoutManager(new LinearLayoutManager(this));
Adapter = new ImageAdapter(JudgeActivity.this, mUploads);
RecyclerView.setAdapter(Adapter);
Also, in Java, variable names follow camelCase
, not TitleCase
. You don't have to follow that guideline, but it makes it less confusing for others when debugging your code.
The issue is the images that are supposed to be displayed aren't displaying but maybe this is due to something else?
– A.Fitzgerald
Nov 13 '18 at 21:34
@A.Fitzgerald it likely is. A ValueEventListener listens for changes in the current DB reference. It doesn't do an initial retrieval of the current values.
– TheWanderer
Nov 13 '18 at 21:35
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286540%2fe-recyclerview-no-adapter-attached-skipping-layout-new%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
Is there actually a problem? That "error" isn't an error, it's just a warning. And it's shown because, when the Activity is first displayed, the RecyclerView has no Adapter set to it. You only set the Adapter when a Firebase value changes, which is a bad idea.
You should create and set the Adapter outside of the ValueEventListener:
RecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerView.setHasFixedSize(true);
RecyclerView.setLayoutManager(new LinearLayoutManager(this));
Adapter = new ImageAdapter(JudgeActivity.this, mUploads);
RecyclerView.setAdapter(Adapter);
Also, in Java, variable names follow camelCase
, not TitleCase
. You don't have to follow that guideline, but it makes it less confusing for others when debugging your code.
The issue is the images that are supposed to be displayed aren't displaying but maybe this is due to something else?
– A.Fitzgerald
Nov 13 '18 at 21:34
@A.Fitzgerald it likely is. A ValueEventListener listens for changes in the current DB reference. It doesn't do an initial retrieval of the current values.
– TheWanderer
Nov 13 '18 at 21:35
add a comment |
Is there actually a problem? That "error" isn't an error, it's just a warning. And it's shown because, when the Activity is first displayed, the RecyclerView has no Adapter set to it. You only set the Adapter when a Firebase value changes, which is a bad idea.
You should create and set the Adapter outside of the ValueEventListener:
RecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerView.setHasFixedSize(true);
RecyclerView.setLayoutManager(new LinearLayoutManager(this));
Adapter = new ImageAdapter(JudgeActivity.this, mUploads);
RecyclerView.setAdapter(Adapter);
Also, in Java, variable names follow camelCase
, not TitleCase
. You don't have to follow that guideline, but it makes it less confusing for others when debugging your code.
The issue is the images that are supposed to be displayed aren't displaying but maybe this is due to something else?
– A.Fitzgerald
Nov 13 '18 at 21:34
@A.Fitzgerald it likely is. A ValueEventListener listens for changes in the current DB reference. It doesn't do an initial retrieval of the current values.
– TheWanderer
Nov 13 '18 at 21:35
add a comment |
Is there actually a problem? That "error" isn't an error, it's just a warning. And it's shown because, when the Activity is first displayed, the RecyclerView has no Adapter set to it. You only set the Adapter when a Firebase value changes, which is a bad idea.
You should create and set the Adapter outside of the ValueEventListener:
RecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerView.setHasFixedSize(true);
RecyclerView.setLayoutManager(new LinearLayoutManager(this));
Adapter = new ImageAdapter(JudgeActivity.this, mUploads);
RecyclerView.setAdapter(Adapter);
Also, in Java, variable names follow camelCase
, not TitleCase
. You don't have to follow that guideline, but it makes it less confusing for others when debugging your code.
Is there actually a problem? That "error" isn't an error, it's just a warning. And it's shown because, when the Activity is first displayed, the RecyclerView has no Adapter set to it. You only set the Adapter when a Firebase value changes, which is a bad idea.
You should create and set the Adapter outside of the ValueEventListener:
RecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerView.setHasFixedSize(true);
RecyclerView.setLayoutManager(new LinearLayoutManager(this));
Adapter = new ImageAdapter(JudgeActivity.this, mUploads);
RecyclerView.setAdapter(Adapter);
Also, in Java, variable names follow camelCase
, not TitleCase
. You don't have to follow that guideline, but it makes it less confusing for others when debugging your code.
answered Nov 13 '18 at 17:43
TheWandererTheWanderer
6,96221028
6,96221028
The issue is the images that are supposed to be displayed aren't displaying but maybe this is due to something else?
– A.Fitzgerald
Nov 13 '18 at 21:34
@A.Fitzgerald it likely is. A ValueEventListener listens for changes in the current DB reference. It doesn't do an initial retrieval of the current values.
– TheWanderer
Nov 13 '18 at 21:35
add a comment |
The issue is the images that are supposed to be displayed aren't displaying but maybe this is due to something else?
– A.Fitzgerald
Nov 13 '18 at 21:34
@A.Fitzgerald it likely is. A ValueEventListener listens for changes in the current DB reference. It doesn't do an initial retrieval of the current values.
– TheWanderer
Nov 13 '18 at 21:35
The issue is the images that are supposed to be displayed aren't displaying but maybe this is due to something else?
– A.Fitzgerald
Nov 13 '18 at 21:34
The issue is the images that are supposed to be displayed aren't displaying but maybe this is due to something else?
– A.Fitzgerald
Nov 13 '18 at 21:34
@A.Fitzgerald it likely is. A ValueEventListener listens for changes in the current DB reference. It doesn't do an initial retrieval of the current values.
– TheWanderer
Nov 13 '18 at 21:35
@A.Fitzgerald it likely is. A ValueEventListener listens for changes in the current DB reference. It doesn't do an initial retrieval of the current values.
– TheWanderer
Nov 13 '18 at 21:35
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286540%2fe-recyclerview-no-adapter-attached-skipping-layout-new%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
please show your code
– Badran
Nov 13 '18 at 17:36