Having Trouble Having More Than One TextView In A ExpandableListView
I seem to be having trouble initializing another textview in my expandablelist. I already have one, but I'm trying to add a second one in the same child. I made a new setter and
Solution 1:
All of your arrays are of different sizes but you're iterating over them in the same for
loop. Your bold[]
has 5
elements, names[]
has 10
, Images[]
only 8
; but, you're accessing them in your for
loop using the variable j
set to iterate 20
times (from 0
to 19
).
That's why you're getting the ArrayIndexOutOfBounds
exception. They should all be of the same length and match your size
variable to let you initialize size
number of Child
objects.
The problem lies with your
Group
class. Notice how both setName()
and setDetail()
are saving the data to Name
class member only. Hence, you are seeing two copies of your data.
public class Group {
private String Name;
private String Detail; // Add a new Detail member
private ArrayList<Child> Items;
public String getName() {
return Name;
}
public String getDetail() {
return Detail; // change getter
}
public void setDetail(String Detail) {
this.Detail = Detail; // change setter
}
public void setName(String name) {
this.Name = name;
}
...
}
Just add a new Detail
class member and update the corresponding getDetail()
and setDetail()
methods as I've done above to fix your problem.
Post a Comment for "Having Trouble Having More Than One TextView In A ExpandableListView"