アダプター
にgetItemメソッドがあるので変更する必要がありFragment
ますView pager
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をフラグメントに追加するにはどうすればよいですか?