所以我的代码包括解析json url并从烂番茄api中获取值。我无法弄清楚如何获得列表视图,当用户点击票房时,他们应该通过票房api进行解析。如果用户点击即将播放的电影,则应该解析该网址。 Parse工作只需要修复我的listview
public class MainActivity extends Activity {
String boxOfficeUrl ="http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?page_limit=50&page=1&country=us&apikey=arjrkxx65yxywyefb8g2xxhs";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new AsyncBox().execute(boxOfficeUrl);
}
protected void onPostExecute(List<Movie> result){
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
答案 0 :(得分:0)
试试这个:
ArrayList <String> listItems = new ArrayList<String>();
ArrayAdapter <String> adapter;
ListView listView;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new AsyncBox().execute(boxOfficeUrl);
listView = (ListView) findViewById(R.id.listView1);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems);
}
protected void onPostExecute(List<Movie> result){
adapter.addAll(result);
}