JSON を使用して Web から写真をアップロードし、それらをギャラリー ビューに配置します。しかし、問題は、この写真の1つをクリックすると、他のアクティビティのテーマが表示されるか、クリックした写真を表示するだけで、ギャラリーを表示する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);
}
}
私は他の活動で何をすべきか、または私は何をすべきですか?