我需要更改我在适配器Fragment
中View pager
有 getItem 方法View pager
@Override
public Fragment getItem(int position) {
fragmentPosition = position;
Log.e("PageAdapter", "Creating fragment at: " + position);
DefinedValues.thumbnailInfo.put("activity", DefinedValues.images);
DefinedValues.thumbnailInfo.put("type", "info");
DefinedValues.thumbnailInfo.put("page", position+ 1 + "");
String request = Json.stringToJson(DefinedValues.thumbnailInfo);
DefinedValues.thumbnailInfo.clear();
StringAsyncRetriever net = new StringAsyncRetriever();
net.setListener(MyPagerAdapter.this);
net.execute(request, DefinedValues.GET_DATA);
Log.d(TAG, "got item @ " + position);
fragment1 myFragment = new fragment1();
return myFragment;
}
我需要在 AsyncTask 完成后将其更改为显示图像的那个
有 fragment1 类:
public class fragment1 extends Fragment {
GridView gridView;
public ImageAdapter adapter;
public int position;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
//
Bundle savedInstanceState) {
adapter = new ImageAdapter(this.getActivity(), position);
if (container == null) {
Log.e("Null container", "Null");
return null;
}
//Log.e("fragment1", "fragment1 reached!");
View view = inflater.inflate(R.layout.menu1_fragment, container, false);
gridView = (GridView)view.findViewById(R.id.gridview1);
gridView.setAdapter(adapter);
DefinedValues.adapterContainer.add(adapter);
//Log.d("Fragment1 adapter count: ", DefinedValues.adapterContainer.size() + "");
/* gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
ImageView imageView = new ImageView(getActivity());
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams
(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
imageView.setLayoutParams(vp);
imageView.setImageBitmap(DefinedValues.imageContainer.get(position).getThumbnail());
getActivity().addContentView(imageView, vp);
}
});
*/
return gridView;
}
那么如何仅在 asyncTask 结束时将 gridView 添加到片段?