Skip to content Skip to sidebar Skip to footer

How To Change The Content Of The Layout?

In my Android application i have a tracker activity in which i retrieve the exercises information(name , period , burned calories) from the sqlite data base based on the selected d

Solution 1:

Its because you defined these variables as static:

publicstaticint icon;
publicstaticString data_text;
publicstaticString text;

As a result only one instance of those variables are created for all instances of that class. So when you create a new Profile each time, they are overwritten with new values. You need to remove the static keyword from variable declarations:

publicint icon;
publicString data_text;
publicString text;

Then you cannot access them as static so you need to access like this:

Profilepli= data[position];
 holder.imgIcon.setImageResource(pli.icon);
 holder.Datatxt.setText(pli.data_text);
 holder.txt.setText(pli.text);

Check out this if you want to learn more about static: http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html

Post a Comment for "How To Change The Content Of The Layout?"