0

I want to retrive values from the getNombre() and put it in a new array not arraylist. The job is done from a background task.

public class Post {

private String nombre;

public void setNombre(String nombre) {

    this.nombre = nombre;

}

public String getNombre() {

    return nombre;

}
}

I call my postlist as follows:

ArrayList<Post> PostList = new ArrayList<Post>();

In my background task I have the following post excuse method.

@Override
protected void onPostExecute(ArrayList<Post> result) {

}

How can I put getNombre() values into a new array, not ArrayList

Dimitri
  • 1,864
  • 7
  • 38
  • 64

1 Answers1

0

You can use following code for putting value returned by getNombre() of all Post in ArrayList into String[].

protected String[] getAllNombres( ArrayList<Post> posts ) {
    String[] nombres = new String[ posts.size ];
    int i = 0;
    for( Post post : posts ) {
        nombres[i++] = post.getNombre();
    }
    return nombres;
}