I have an ArrayList called results that uses the class ItemObjects when I want to add an item in results. My problem is that I cannot manage to retrieve a specific String from an item.
The class code is:
public class ItemObjects {
private String mText1;
private String mText2;
public ItemObjects(String text1, String text2){
mText1 = text1;
mText2 = text2;
}
public String getmText1() {
return mText1;
}
public void setmText1(String mText1) {
this.mText1 = mText1;
}
public String getmText2() {
return mText2;
}
public void setmText2(String mText2) {
this.mText2 = mText2;
}
}
And I use the following code to add an item into the ArrayList:
ArrayList results = new ArrayList<ItemObjects>();
//THis part goes inside a for using i as increment;
ItemObjects obj = new ItemObjects(type, sender);
results.add(i , obj);
I have tried several things to retrieve the data such as:
String type = ItemObjects.getmText1();
or:
String type= results.get(i);
the first try, only retrieves the mText1 from the first item, and the second is an object and I dn't know how i should get the mText1 from it.
Any help would be appreciated :)