我有一个字符串集合,并使用
将字符串分别声明为数组ArrayList<String> al=new ArrayList<String>();
使用
调用程序中的数组al=getIntent().getStringArrayListExtra("titles");
现在,我没有声明每个数组,而是像下面那样创建了SongsArray.java ......
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;
}
}
现在我想调用我声明的数组。我怎样才能做到这一点???我想单独获取每个字符串的值...
答案 0 :(得分:0)
请勿使用ArrayList<String>
而是使用ArrayList<SongArray>
:
List<SongArray> songs = new ArrayList<SongArray>();
songs.add(new SongArray(...);
Toast.makeText(this, songs.get(0).gettitle(), 200).show();