I am defining array strings into String.xml. Then I am going to add them into ArrayList. But I got an empty list.
String.xml:
<array name="restaurant_names">
<item >Tobaz</item>
<item >Lozanna</item>
<item >Vetameen</item>
<item >Baharat</item>
</array>
Java class:
ArrayList<RestaurantObjects> restaurant;
String name;
String type;
restaurant = new ArrayList<>();
for(int i=0;i>=R.array.restaurant_names;i++) {
name = getResources().getStringArray(R.array.restaurant_names)[i];
type = getResources().getStringArray(R.array.restaurant_names)[i];
restaurant.add(new RestaurantObjects(name, type));
}
restaurantList.setAdapter(new ListAdapter(this,restaurant));
I tried to do it without the loop and it works perfect. is there something wrong with the for loop.