Unten ist die Liste Klasse.speichern arraylist aus bestehenden arraylist in android
public class Abc {
String pincode, state, name, phNo;
public Abc(String pincode, String state, String name, String phNo) {
this.pincode = pincode;
this.state = state;
this.name = name;
this.phNo = phNo;
}
public String getPincode() {
return pincode;
}
public void setPincode(String pincode) {
this.pincode = pincode;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhNo() {
return phNo;
}
public void setPhNo(String phNo) {
this.phNo = phNo;
}
}
Ich füge die Daten der Liste hinzu.
List<Abc> abcs = new ArrayList<>();
List<Abc> customList = new ArrayList<>();
abcs.add(new Abc("600025", "Delhi", "gambhir", "565632552"));
abcs.add(new Abc("600026", "Punjab", "yuvi", "565632553"));
abcs.add(new Abc("600027", "Punjab", "bhajji", "565632554"));
abcs.add(new Abc("600028", "Delhi", "kohli", "565632555"));
abcs.add(new Abc("600029", "Karnataka", "dravid", "565632556"));
abcs.add(new Abc("600030", "Delhi", "rohit", "565632557"));
abcs.add(new Abc("600031", "Kerla", "sreeshanth", "565632558"));
Ich brauche eine separate Liste, die in Delhi lebt, wie man diese Logik erreicht. Ich habe versucht, wie diese
for (int i = 0; i < abcs.size(); i++) {
if(abcs.get(i).getName().equals("Delhi")){
customList.addAll(i,abcs);
}
}
Aber in meinem Custom keine Daten hinzugefügt. Kann mir jemand helfen.
versuchen, das ABC-Klasse-Objekt in Ihrer Custom setzen. ** customList.add (abcs.get (i)); ** –
warten .. Ich werde überprüfen .. – Balaji
Diese Bedingung 'if (abcs.get (i) .getName(). Ist gleich (" Delhi ")) {'sollte' sein if (abcs.get (i) .getState(). equals ("Delhi")) {' – Piyush