How to give serial number in RecyclerView using adapter class in android?How to save an Android Activity state using save instance state?Why is the Android emulator so slow? How can we speed up the Android emulator?How to get the build/version number of your Android application?Update ViewPager dynamically?How to add dividers and spaces between items in RecyclerView?How to create RecyclerView with multiple view type?Scrolling lagged after applying the typeface in the Recycler view itemsPass position in ListView to child RecyclerView AdapterRecycler View position comparisonWhy onBindViewHolder index isn't incrementing in Recycler View?
Can both line and load go to same screw on a GFCI outlet?
FPGA CPU's, how to find the max speed?
What's the phrasal verb for carbonated drinks exploding out of the can after being shaken?
Short story, maybe by Budrys: unpleasant man makes himself conspicuous to attract aliens
Mathematica function equivalent to Matlab's residue function (partial fraction expansion)
Why don't commercial aircraft adopt a slightly more seaplane-like design to allow safer ditching in case of emergency?
Why aren't globular clusters disk shaped
Is there a way to handmake alphabet pasta?
What to look for in climbing shoes?
Are the errors in this formulation of the simple linear regression model random variables?
What impact would a dragon the size of Asia have on the environment?
What exactly is a Hadouken?
Creating a character, is Noble a class or a background?
What is the technical explanation of the note "A♭" in a F7 chord in the key of C?
Was all the fuel expended in each stage of a Saturn V launch?
In Adventurers League, is there any way for an 5th-level wizard to gain heavy armor proficiency?
Remove cardinal direction letters
Project Euler, problem # 9, Pythagorean triplet
Why is "dark" an adverb in this sentence?
A scene of Jimmy diversity
Why limit to revolvers?
Why doesn't philosophy have higher standards for its arguments?
What are "full piece" and "half piece" in chess?
I won USD 50K! Now what should I do with it?
How to give serial number in RecyclerView using adapter class in android?
How to save an Android Activity state using save instance state?Why is the Android emulator so slow? How can we speed up the Android emulator?How to get the build/version number of your Android application?Update ViewPager dynamically?How to add dividers and spaces between items in RecyclerView?How to create RecyclerView with multiple view type?Scrolling lagged after applying the typeface in the Recycler view itemsPass position in ListView to child RecyclerView AdapterRecycler View position comparisonWhy 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 want to add serial number for dynamic response in recycler view from server. what i do please suggest me..
Context context;
List<Ordere> orderes;
public MyRewardsAdapter(Context context, List<Ordere> orderes)
this.context = context;
this.orderes = orderes;
@Override
public MyRewardsViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
View view = LayoutInflater.from(context).inflate(R.layout.reward_list_items,null);
MyRewardsViewHolder myRewardsViewHolder = new MyRewardsViewHolder(context, view);
return myRewardsViewHolder;
@Override
public void onBindViewHolder(MyRewardsViewHolder holder, int position)
holder.txtRewardid.setText(orderes.get(position).getOrderid());
holder.txtrewardpoint.setText(orderes.get(position).getTotal_point());
holder.txtRewardDate.setText(orderes.get(position).getDate());
@Override
public int getItemCount()
return orderes.size();
android android-recyclerview
add a comment |
i want to add serial number for dynamic response in recycler view from server. what i do please suggest me..
Context context;
List<Ordere> orderes;
public MyRewardsAdapter(Context context, List<Ordere> orderes)
this.context = context;
this.orderes = orderes;
@Override
public MyRewardsViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
View view = LayoutInflater.from(context).inflate(R.layout.reward_list_items,null);
MyRewardsViewHolder myRewardsViewHolder = new MyRewardsViewHolder(context, view);
return myRewardsViewHolder;
@Override
public void onBindViewHolder(MyRewardsViewHolder holder, int position)
holder.txtRewardid.setText(orderes.get(position).getOrderid());
holder.txtrewardpoint.setText(orderes.get(position).getTotal_point());
holder.txtRewardDate.setText(orderes.get(position).getDate());
@Override
public int getItemCount()
return orderes.size();
android android-recyclerview
In onBind you have an attribute called position
– Santanu Sur
Mar 26 at 7:40
yes, i have but how to add in textView ~santanu
– Parveen Haade
Mar 26 at 8:17
add a comment |
i want to add serial number for dynamic response in recycler view from server. what i do please suggest me..
Context context;
List<Ordere> orderes;
public MyRewardsAdapter(Context context, List<Ordere> orderes)
this.context = context;
this.orderes = orderes;
@Override
public MyRewardsViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
View view = LayoutInflater.from(context).inflate(R.layout.reward_list_items,null);
MyRewardsViewHolder myRewardsViewHolder = new MyRewardsViewHolder(context, view);
return myRewardsViewHolder;
@Override
public void onBindViewHolder(MyRewardsViewHolder holder, int position)
holder.txtRewardid.setText(orderes.get(position).getOrderid());
holder.txtrewardpoint.setText(orderes.get(position).getTotal_point());
holder.txtRewardDate.setText(orderes.get(position).getDate());
@Override
public int getItemCount()
return orderes.size();
android android-recyclerview
i want to add serial number for dynamic response in recycler view from server. what i do please suggest me..
Context context;
List<Ordere> orderes;
public MyRewardsAdapter(Context context, List<Ordere> orderes)
this.context = context;
this.orderes = orderes;
@Override
public MyRewardsViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
View view = LayoutInflater.from(context).inflate(R.layout.reward_list_items,null);
MyRewardsViewHolder myRewardsViewHolder = new MyRewardsViewHolder(context, view);
return myRewardsViewHolder;
@Override
public void onBindViewHolder(MyRewardsViewHolder holder, int position)
holder.txtRewardid.setText(orderes.get(position).getOrderid());
holder.txtrewardpoint.setText(orderes.get(position).getTotal_point());
holder.txtRewardDate.setText(orderes.get(position).getDate());
@Override
public int getItemCount()
return orderes.size();
android android-recyclerview
android android-recyclerview
edited Mar 26 at 7:33
Vadim Kotov
5,2787 gold badges36 silver badges50 bronze badges
5,2787 gold badges36 silver badges50 bronze badges
asked Mar 26 at 7:31
Parveen HaadeParveen Haade
551 silver badge11 bronze badges
551 silver badge11 bronze badges
In onBind you have an attribute called position
– Santanu Sur
Mar 26 at 7:40
yes, i have but how to add in textView ~santanu
– Parveen Haade
Mar 26 at 8:17
add a comment |
In onBind you have an attribute called position
– Santanu Sur
Mar 26 at 7:40
yes, i have but how to add in textView ~santanu
– Parveen Haade
Mar 26 at 8:17
In onBind you have an attribute called position
– Santanu Sur
Mar 26 at 7:40
In onBind you have an attribute called position
– Santanu Sur
Mar 26 at 7:40
yes, i have but how to add in textView ~santanu
– Parveen Haade
Mar 26 at 8:17
yes, i have but how to add in textView ~santanu
– Parveen Haade
Mar 26 at 8:17
add a comment |
1 Answer
1
active
oldest
votes
If you want to show serial number starting from 0 you can directly use viewholder.getAdapterPosition()
. If you want to start it from 1 just add it viewholder.getAdapterPosition()+1
before you set it in any textview.
yes, it is right but how to set this position value in textView ~ @Karan Mer
– Parveen Haade
Mar 26 at 8:16
you can simply concatenate it liketv1.setText(""+viewholder.getAdapterPosition())
– karan
Mar 26 at 8:26
By mistake I had added the id of the another textview.
– Parveen Haade
Mar 26 at 8:42
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%2f55351839%2fhow-to-give-serial-number-in-recyclerview-using-adapter-class-in-android%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
If you want to show serial number starting from 0 you can directly use viewholder.getAdapterPosition()
. If you want to start it from 1 just add it viewholder.getAdapterPosition()+1
before you set it in any textview.
yes, it is right but how to set this position value in textView ~ @Karan Mer
– Parveen Haade
Mar 26 at 8:16
you can simply concatenate it liketv1.setText(""+viewholder.getAdapterPosition())
– karan
Mar 26 at 8:26
By mistake I had added the id of the another textview.
– Parveen Haade
Mar 26 at 8:42
add a comment |
If you want to show serial number starting from 0 you can directly use viewholder.getAdapterPosition()
. If you want to start it from 1 just add it viewholder.getAdapterPosition()+1
before you set it in any textview.
yes, it is right but how to set this position value in textView ~ @Karan Mer
– Parveen Haade
Mar 26 at 8:16
you can simply concatenate it liketv1.setText(""+viewholder.getAdapterPosition())
– karan
Mar 26 at 8:26
By mistake I had added the id of the another textview.
– Parveen Haade
Mar 26 at 8:42
add a comment |
If you want to show serial number starting from 0 you can directly use viewholder.getAdapterPosition()
. If you want to start it from 1 just add it viewholder.getAdapterPosition()+1
before you set it in any textview.
If you want to show serial number starting from 0 you can directly use viewholder.getAdapterPosition()
. If you want to start it from 1 just add it viewholder.getAdapterPosition()+1
before you set it in any textview.
answered Mar 26 at 7:37
karankaran
6,4263 gold badges26 silver badges65 bronze badges
6,4263 gold badges26 silver badges65 bronze badges
yes, it is right but how to set this position value in textView ~ @Karan Mer
– Parveen Haade
Mar 26 at 8:16
you can simply concatenate it liketv1.setText(""+viewholder.getAdapterPosition())
– karan
Mar 26 at 8:26
By mistake I had added the id of the another textview.
– Parveen Haade
Mar 26 at 8:42
add a comment |
yes, it is right but how to set this position value in textView ~ @Karan Mer
– Parveen Haade
Mar 26 at 8:16
you can simply concatenate it liketv1.setText(""+viewholder.getAdapterPosition())
– karan
Mar 26 at 8:26
By mistake I had added the id of the another textview.
– Parveen Haade
Mar 26 at 8:42
yes, it is right but how to set this position value in textView ~ @Karan Mer
– Parveen Haade
Mar 26 at 8:16
yes, it is right but how to set this position value in textView ~ @Karan Mer
– Parveen Haade
Mar 26 at 8:16
you can simply concatenate it like
tv1.setText(""+viewholder.getAdapterPosition())
– karan
Mar 26 at 8:26
you can simply concatenate it like
tv1.setText(""+viewholder.getAdapterPosition())
– karan
Mar 26 at 8:26
By mistake I had added the id of the another textview.
– Parveen Haade
Mar 26 at 8:42
By mistake I had added the id of the another textview.
– Parveen Haade
Mar 26 at 8:42
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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%2f55351839%2fhow-to-give-serial-number-in-recyclerview-using-adapter-class-in-android%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
In onBind you have an attribute called position
– Santanu Sur
Mar 26 at 7:40
yes, i have but how to add in textView ~santanu
– Parveen Haade
Mar 26 at 8:17