我的菜单选项按钮与读取HTTP数据的类不在一个类中。而且它给我“PhotoGalleryFragment不是一个封闭类”为不是封闭类
new PhotoGalleryFragment.FetchItemsTask("top-rated").execute();
PhotoGalleryActivity.java错误 - 在这里,我想使它所以当按下“最受好评的电影”按钮时,它通过“顶级的流行”的说法为FetchItemsTask从运行并更改API的网址,并更改返回的JSON‘’到‘顶级’
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.topRatedMovies) {
Toast.makeText(getApplicationContext(), "Top Rated Movie selected", Toast.LENGTH_LONG).show();
new PhotoGalleryFragment.FetchItemsTask("top-rated").execute();
return true;
}
return super.onOptionsItemSelected(item);
}
PhotoGalleryFragment.java - 在这里,我想取数据。
public class FetchItemsTask extends AsyncTask<Void,Void,List<MovieItem>> {
private String mQuery;
public FetchItemsTask(String query) {
mQuery = query;
}
@Override
protected List<MovieItem> doInBackground(Void... params) {
return new MovieFetchr().fetchItems(mQuery);
}
@Override
protected void onPostExecute(List<MovieItem> items) {
mItems = items;
for (int i = 0; i < mItems.size(); i++) {
}
setupAdapter();
}
}
我该如何解决这个问题?谢谢。