开发者

Getting the values from an array in android

I have a collection of strings and declared the strings individually as arrays using

ArrayList<String> al=new ArrayList<String>();

and called the arrays in the program by using

al=getIntent().getStringArrayListExt开发者_如何学Pythonra("titles");

Now, instead of declaring each of the arrays i have created SongsArray.java like below...

public class SongsArray {
private String title;
private String movieName;
private String singerName;
private String imagePath;
private String mediaPath;

public String gettitle() 
{
    return title;
}
public void settitle(String title) {
    this.title = title;
}
public String getmovieName() {
    return movieName;
}
public void setmovieName(String movieName) {
    this.movieName = movieName;
}
public String getsingerName() {
    return singerName;
}
public void setsingerName(String singerName) {
    this.singerName = singerName;
}
public String getimagePath() {
    return imagePath;
}
public void setimagePath(String imagePath) {
    this.imagePath = imagePath;
}
public String getmediaPath() {
    return mediaPath;
}
public void setmediaPath(String mediaPath) {
    this.mediaPath = mediaPath;
}

}

Now i want to call the arrays that i have declared. How can i do that??? I want to get values of each string individually...


Don't use ArrayList<String> and instead use ArrayList<SongArray>:

List<SongArray> songs = new ArrayList<SongArray>();
songs.add(new SongArray(...);
Toast.makeText(this, songs.get(0).gettitle(), 200).show();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜