Android Viewgroup IssuesIs there a way to run Python on Android?How to save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?“Debug certificate expired” error in Eclipse Android pluginsIs there a unique Android device ID?What is 'Context' on Android?Proper use cases for Android UserManager.isUserAGoat()?Scrolling lagged after applying the typeface in the Recycler view itemsWhy onBindViewHolder index isn't incrementing in Recycler View?
What are the limitations of the Hendersson-Hasselbalch equation?
Is it possible to use reference type alias with pointer operator to declare a reference to pointer?
Is a text with orthographic or grammatic mistakes in a language X still a text in that language X?
would a winged human/angel build like this be able to fly? (see image below)
Pronouns when writing from the point of view of a robot
Can a Hogwarts student refuse the Sorting Hat's decision?
How to prevent Deadlock on SELECT queries?
Broken bottom bracket?
Why do my fried eggs start browning very fast?
What could prevent players from leaving an island?
Is there any difference between "result in" and "end up with"?
Write The Shortest Program to Calculate Height of a Binary Tree
conditional probability of dependent random variables
Is space radiation a risk for space film photography, and how is this prevented?
Why is Heisenberg shown dead in Negro y Azul?
How does Rust's 128-bit integer `i128` work on a 64-bit system?
Does a humanoid possessed by a ghost register as undead to a paladin's Divine Sense?
Probably terminated or laid off soon; confront or not?
If someone else uploads my GPL'd code to Github without my permission, is that a copyright violation?
what can you do with Format View
Piece de Resistance - Introduction & Ace and A's
Programmatically drawing sinusoids with tikz
What is the difference between "un plan" and "une carte" (in the context of map)?
Which one is more important between endgame studies and tactics?
Android Viewgroup Issues
Is there a way to run Python on Android?How to save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?“Debug certificate expired” error in Eclipse Android pluginsIs there a unique Android device ID?What is 'Context' on Android?Proper use cases for Android UserManager.isUserAGoat()?Scrolling lagged after applying the typeface in the Recycler view itemsWhy onBindViewHolder index isn't incrementing in Recycler View?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have an issue using a viewGroup, for some reason the id doesn't process the statement, and really I tried everything, can you help please?
I don't know if it is something about the version3.3.2 or what's wrong with the code
public class popularAdapter extends RecyclerView.Adapter<popularAdapter.ImageViewHolder>
private Context mContext;
private List<popular> mPopulars;
public popularAdapter (Context context,List<popular>populars)
mContext=context;
mPopulars=populars;
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
//HERE IS THE ISSUE
View v= LayoutInflater.from(mContext).inflate(R.layout.popular_item2,viewGroup,false);
return new ImageViewHolder(v);
@Override
public void onBindViewHolder(ImageViewHolder holder, int position)
popular popularCur=mPopulars.get(position);
ImageViewHolder.prodName.setText(popularCur.getProduc_name());
@Override
public int getItemCount()
return 0;
public class ImageViewHolder extends RecyclerView.ViewHolder
public TextView prd_name;
public TextView prd_price;
public TextView prd_img;
public ImageViewHolder(View itemView)
super(itemView);
prd_name =itemView.findViewById(R.id.prodName);
prd_price=itemView.findViewById(R.id.prodPrice);
prd_img =itemView.findViewById(R.id.prodImageHolder);
add a comment |
I have an issue using a viewGroup, for some reason the id doesn't process the statement, and really I tried everything, can you help please?
I don't know if it is something about the version3.3.2 or what's wrong with the code
public class popularAdapter extends RecyclerView.Adapter<popularAdapter.ImageViewHolder>
private Context mContext;
private List<popular> mPopulars;
public popularAdapter (Context context,List<popular>populars)
mContext=context;
mPopulars=populars;
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
//HERE IS THE ISSUE
View v= LayoutInflater.from(mContext).inflate(R.layout.popular_item2,viewGroup,false);
return new ImageViewHolder(v);
@Override
public void onBindViewHolder(ImageViewHolder holder, int position)
popular popularCur=mPopulars.get(position);
ImageViewHolder.prodName.setText(popularCur.getProduc_name());
@Override
public int getItemCount()
return 0;
public class ImageViewHolder extends RecyclerView.ViewHolder
public TextView prd_name;
public TextView prd_price;
public TextView prd_img;
public ImageViewHolder(View itemView)
super(itemView);
prd_name =itemView.findViewById(R.id.prodName);
prd_price=itemView.findViewById(R.id.prodPrice);
prd_img =itemView.findViewById(R.id.prodImageHolder);
I think the problem is with the context you are sending.See my answer down there.Try that solution.
– Brahma Datta
Mar 27 at 5:46
1
@g.brahmaDatta sir not in here context check he returning 0 in item count
– Ashvin solanki
Mar 27 at 5:50
1
yeah nice point @Ashvinsolanki
– Brahma Datta
Mar 27 at 5:55
did you solve your problem ?
– Ashvin solanki
Mar 27 at 10:02
add a comment |
I have an issue using a viewGroup, for some reason the id doesn't process the statement, and really I tried everything, can you help please?
I don't know if it is something about the version3.3.2 or what's wrong with the code
public class popularAdapter extends RecyclerView.Adapter<popularAdapter.ImageViewHolder>
private Context mContext;
private List<popular> mPopulars;
public popularAdapter (Context context,List<popular>populars)
mContext=context;
mPopulars=populars;
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
//HERE IS THE ISSUE
View v= LayoutInflater.from(mContext).inflate(R.layout.popular_item2,viewGroup,false);
return new ImageViewHolder(v);
@Override
public void onBindViewHolder(ImageViewHolder holder, int position)
popular popularCur=mPopulars.get(position);
ImageViewHolder.prodName.setText(popularCur.getProduc_name());
@Override
public int getItemCount()
return 0;
public class ImageViewHolder extends RecyclerView.ViewHolder
public TextView prd_name;
public TextView prd_price;
public TextView prd_img;
public ImageViewHolder(View itemView)
super(itemView);
prd_name =itemView.findViewById(R.id.prodName);
prd_price=itemView.findViewById(R.id.prodPrice);
prd_img =itemView.findViewById(R.id.prodImageHolder);
I have an issue using a viewGroup, for some reason the id doesn't process the statement, and really I tried everything, can you help please?
I don't know if it is something about the version3.3.2 or what's wrong with the code
public class popularAdapter extends RecyclerView.Adapter<popularAdapter.ImageViewHolder>
private Context mContext;
private List<popular> mPopulars;
public popularAdapter (Context context,List<popular>populars)
mContext=context;
mPopulars=populars;
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
//HERE IS THE ISSUE
View v= LayoutInflater.from(mContext).inflate(R.layout.popular_item2,viewGroup,false);
return new ImageViewHolder(v);
@Override
public void onBindViewHolder(ImageViewHolder holder, int position)
popular popularCur=mPopulars.get(position);
ImageViewHolder.prodName.setText(popularCur.getProduc_name());
@Override
public int getItemCount()
return 0;
public class ImageViewHolder extends RecyclerView.ViewHolder
public TextView prd_name;
public TextView prd_price;
public TextView prd_img;
public ImageViewHolder(View itemView)
super(itemView);
prd_name =itemView.findViewById(R.id.prodName);
prd_price=itemView.findViewById(R.id.prodPrice);
prd_img =itemView.findViewById(R.id.prodImageHolder);
edited Mar 27 at 5:41
Zoe
15.4k9 gold badges65 silver badges97 bronze badges
15.4k9 gold badges65 silver badges97 bronze badges
asked Mar 27 at 2:34
The MechanicThe Mechanic
111 bronze badge
111 bronze badge
I think the problem is with the context you are sending.See my answer down there.Try that solution.
– Brahma Datta
Mar 27 at 5:46
1
@g.brahmaDatta sir not in here context check he returning 0 in item count
– Ashvin solanki
Mar 27 at 5:50
1
yeah nice point @Ashvinsolanki
– Brahma Datta
Mar 27 at 5:55
did you solve your problem ?
– Ashvin solanki
Mar 27 at 10:02
add a comment |
I think the problem is with the context you are sending.See my answer down there.Try that solution.
– Brahma Datta
Mar 27 at 5:46
1
@g.brahmaDatta sir not in here context check he returning 0 in item count
– Ashvin solanki
Mar 27 at 5:50
1
yeah nice point @Ashvinsolanki
– Brahma Datta
Mar 27 at 5:55
did you solve your problem ?
– Ashvin solanki
Mar 27 at 10:02
I think the problem is with the context you are sending.See my answer down there.Try that solution.
– Brahma Datta
Mar 27 at 5:46
I think the problem is with the context you are sending.See my answer down there.Try that solution.
– Brahma Datta
Mar 27 at 5:46
1
1
@g.brahmaDatta sir not in here context check he returning 0 in item count
– Ashvin solanki
Mar 27 at 5:50
@g.brahmaDatta sir not in here context check he returning 0 in item count
– Ashvin solanki
Mar 27 at 5:50
1
1
yeah nice point @Ashvinsolanki
– Brahma Datta
Mar 27 at 5:55
yeah nice point @Ashvinsolanki
– Brahma Datta
Mar 27 at 5:55
did you solve your problem ?
– Ashvin solanki
Mar 27 at 10:02
did you solve your problem ?
– Ashvin solanki
Mar 27 at 10:02
add a comment |
3 Answers
3
active
oldest
votes
problem is here
you will never get any items in RecyclerView because you are returning 0 in getItemCount
@Override
public int getItemCount()
//return 0 ?
return 0;
change with
@Override
public int getItemCount()
return mPopulars.size();
getItemCount
int getItemCount ()
Returns the total number of items in the data set held by the adapter.
add a comment |
Try this solution
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
View v= LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.popular_item2,viewGroup,false);
return new ImageViewHolder(v);
add a comment |
Optimizing @Ashwin solanki answer
Change following code
@Override
public int getItemCount()
//return 0 ?
return 0;
to
@Override
public int getItemCount()
//return 0 ?
if(mPopulars != null)
return mPopulars.size();
return 0;
Description: onCreateViewHolder and onBindViewHolder methods get called for the count which is returned by getItemCount method. As your code is always returning 0, these methods will not get called and list will not get populated on UI.
Also, check following line from you code from onBindViewHolder method:
ImageViewHolder.prodName.setText(popularCur.getProduc_name());
You are considering 'prodName' variable of 'ImageViewHolder' class as static but it is not. Instead it should be
holder.prodName.setText(popularCur.getProduc_name());
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%2f55368939%2fandroid-viewgroup-issues%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
problem is here
you will never get any items in RecyclerView because you are returning 0 in getItemCount
@Override
public int getItemCount()
//return 0 ?
return 0;
change with
@Override
public int getItemCount()
return mPopulars.size();
getItemCount
int getItemCount ()
Returns the total number of items in the data set held by the adapter.
add a comment |
problem is here
you will never get any items in RecyclerView because you are returning 0 in getItemCount
@Override
public int getItemCount()
//return 0 ?
return 0;
change with
@Override
public int getItemCount()
return mPopulars.size();
getItemCount
int getItemCount ()
Returns the total number of items in the data set held by the adapter.
add a comment |
problem is here
you will never get any items in RecyclerView because you are returning 0 in getItemCount
@Override
public int getItemCount()
//return 0 ?
return 0;
change with
@Override
public int getItemCount()
return mPopulars.size();
getItemCount
int getItemCount ()
Returns the total number of items in the data set held by the adapter.
problem is here
you will never get any items in RecyclerView because you are returning 0 in getItemCount
@Override
public int getItemCount()
//return 0 ?
return 0;
change with
@Override
public int getItemCount()
return mPopulars.size();
getItemCount
int getItemCount ()
Returns the total number of items in the data set held by the adapter.
edited Mar 27 at 6:24
answered Mar 27 at 5:49
Ashvin solankiAshvin solanki
2,0048 silver badges34 bronze badges
2,0048 silver badges34 bronze badges
add a comment |
add a comment |
Try this solution
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
View v= LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.popular_item2,viewGroup,false);
return new ImageViewHolder(v);
add a comment |
Try this solution
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
View v= LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.popular_item2,viewGroup,false);
return new ImageViewHolder(v);
add a comment |
Try this solution
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
View v= LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.popular_item2,viewGroup,false);
return new ImageViewHolder(v);
Try this solution
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
View v= LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.popular_item2,viewGroup,false);
return new ImageViewHolder(v);
answered Mar 27 at 5:45
Brahma DattaBrahma Datta
7284 silver badges14 bronze badges
7284 silver badges14 bronze badges
add a comment |
add a comment |
Optimizing @Ashwin solanki answer
Change following code
@Override
public int getItemCount()
//return 0 ?
return 0;
to
@Override
public int getItemCount()
//return 0 ?
if(mPopulars != null)
return mPopulars.size();
return 0;
Description: onCreateViewHolder and onBindViewHolder methods get called for the count which is returned by getItemCount method. As your code is always returning 0, these methods will not get called and list will not get populated on UI.
Also, check following line from you code from onBindViewHolder method:
ImageViewHolder.prodName.setText(popularCur.getProduc_name());
You are considering 'prodName' variable of 'ImageViewHolder' class as static but it is not. Instead it should be
holder.prodName.setText(popularCur.getProduc_name());
add a comment |
Optimizing @Ashwin solanki answer
Change following code
@Override
public int getItemCount()
//return 0 ?
return 0;
to
@Override
public int getItemCount()
//return 0 ?
if(mPopulars != null)
return mPopulars.size();
return 0;
Description: onCreateViewHolder and onBindViewHolder methods get called for the count which is returned by getItemCount method. As your code is always returning 0, these methods will not get called and list will not get populated on UI.
Also, check following line from you code from onBindViewHolder method:
ImageViewHolder.prodName.setText(popularCur.getProduc_name());
You are considering 'prodName' variable of 'ImageViewHolder' class as static but it is not. Instead it should be
holder.prodName.setText(popularCur.getProduc_name());
add a comment |
Optimizing @Ashwin solanki answer
Change following code
@Override
public int getItemCount()
//return 0 ?
return 0;
to
@Override
public int getItemCount()
//return 0 ?
if(mPopulars != null)
return mPopulars.size();
return 0;
Description: onCreateViewHolder and onBindViewHolder methods get called for the count which is returned by getItemCount method. As your code is always returning 0, these methods will not get called and list will not get populated on UI.
Also, check following line from you code from onBindViewHolder method:
ImageViewHolder.prodName.setText(popularCur.getProduc_name());
You are considering 'prodName' variable of 'ImageViewHolder' class as static but it is not. Instead it should be
holder.prodName.setText(popularCur.getProduc_name());
Optimizing @Ashwin solanki answer
Change following code
@Override
public int getItemCount()
//return 0 ?
return 0;
to
@Override
public int getItemCount()
//return 0 ?
if(mPopulars != null)
return mPopulars.size();
return 0;
Description: onCreateViewHolder and onBindViewHolder methods get called for the count which is returned by getItemCount method. As your code is always returning 0, these methods will not get called and list will not get populated on UI.
Also, check following line from you code from onBindViewHolder method:
ImageViewHolder.prodName.setText(popularCur.getProduc_name());
You are considering 'prodName' variable of 'ImageViewHolder' class as static but it is not. Instead it should be
holder.prodName.setText(popularCur.getProduc_name());
answered Mar 27 at 6:23
Virat18Virat18
1,1741 gold badge12 silver badges25 bronze badges
1,1741 gold badge12 silver badges25 bronze badges
add a comment |
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%2f55368939%2fandroid-viewgroup-issues%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
I think the problem is with the context you are sending.See my answer down there.Try that solution.
– Brahma Datta
Mar 27 at 5:46
1
@g.brahmaDatta sir not in here context check he returning 0 in item count
– Ashvin solanki
Mar 27 at 5:50
1
yeah nice point @Ashvinsolanki
– Brahma Datta
Mar 27 at 5:55
did you solve your problem ?
– Ashvin solanki
Mar 27 at 10:02