我上了这两个课。下面的应该得到一个带有电影的 ArrayList ......
import java.util.ArrayList ;
import android.app.Activity ;
import android.os.Bundle ;
public class UIDActivity extends Activity {
private static ArrayList<Movie> movieList;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public static void main(String String, int
int args[]
) {
movieList = new ArrayList<Movie>();
movie1 = new Movie("Fight Club", "David Fincher", "1999", "3");
movieList.add(movie1);
}
public String getTitle() {
return title;
}
public String getDirector() {
return director;
}
public int getYear() {
return year;
}
public int getRating() {
return rating;
}
}
这是 Movie 类,我在其中讲述了 Movie 的属性
import java.io.Serializable ;
@SuppressWarnings("serial")
public class Movie implements Serializable {
public String title;
public String director;
public int year;
public int rating;
public Movie(String deTitle, String deDirector, int hetYear, int deRating) {
title = deTitle;
director = deDirector;
year = hetYear;
rating = deRating;
}
public void setTitle(String title) {
this.title = title;
}
public void setDirector(String director) {
this.director = director;
}
public void setYear(int year) {
this.year = year;
}
public void setRating(int rating) {
this.rating = rating;
}
}
出于某种原因,我无法弄清楚我一直忘记什么简单的事情?!?!Eclipse 想将我的公共电影更改为四倍字符串......那里没有错误,但休息也不起作用。