我使用 JSON 从网络上传图片并将它们放在画廊视图中。但问题是我希望当我点击其中一张图片时,它会在其他活动上显示主题或者不知道是什么,只显示我点击的图片,这是显示画廊的 Java 代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
cacheDir = StorageUtils.getOwnCacheDirectory(this, "WydadNewsImageLoader/Cache");
imageLoader = ImageLoader.getInstance();
config = new ImageLoaderConfiguration.Builder(this)
.memoryCacheExtraOptions(480, 800)
.discCacheExtraOptions(480, 800, CompressFormat.JPEG, 75)
.threadPoolSize(3)
.threadPriority(Thread.NORM_PRIORITY - 1)
.denyCacheImageMultipleSizesInMemory()
.offOutOfMemoryHandling()
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))
.discCache(new UnlimitedDiscCache(cacheDir))
.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
.imageDownloader(new URLConnectionImageDownloader(5 * 1000, 20 * 1000))
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.build();
imageLoader.init(config);
options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.photo_porfile_commentaire)
.showImageForEmptyUri(R.drawable.photo_porfile_commentaire).cacheInMemory()
.cacheOnDisc().imageScaleType(ImageScaleType.POWER_OF_2)
.build();
galleryView = (Gallery)findViewById(R.id.gallery1);
//galleryView.setAdapter();
init();
}
public void init(){
new FetchPlayers().execute();
}
class ImageAdapter extends ArrayAdapter<Players> {
public ImageAdapter(Context context, int textViewResourceId, List<Players> objects) {
super(context, textViewResourceId, objects);
}
public View getView(int position, View convertView, ViewGroup parent) {
inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View vi=convertView;
Players players = getItem(position);
if(convertView==null){
vi = inflater.inflate(R.layout.pictures, null);
ImageView image=(ImageView) vi.findViewById(R.id.imageView1);
TextView text1=(TextView)vi.findViewById(R.id.textView1);
TextView text2=(TextView)vi.findViewById(R.id.textNom);
TextView text3=(TextView)vi.findViewById(R.id.textPost);
TextView text4=(TextView)vi.findViewById(R.id.textDdn);
text1.setText(players.getNm());
text2.setText(Html.fromHtml( players.getNom()).toString());
text3.setText(Html.fromHtml( players.getPost()).toString());
text4.setText(players.getDdn());
imageLoader.displayImage(players.getImage(), image, options);
}
return vi;
}
public void onClick(View arg0) {
players = Services.getPlayers(Gallery_Activity.this);
Intent newintent = new Intent(Gallery_Activity.this, Gallery_Player.class);
newintent.putExtra("image", R.imgviews.imgplayer);
startActivity(newintent);
}
}
class FetchPlayers extends AsyncTask<Void, Void, Void> {
private ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = ProgressDialog.show(Gallery_Activity.this, "", getString(R.string.loading_message));
}
@Override
protected Void doInBackground(Void... params) {
players = Services.getPlayers(Gallery_Activity.this);
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
progressDialog.dismiss();
progressDialog.setCancelable(true);
}
}
我应该在其他活动中做什么或我应该做什么?