• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Intent

Hi will anyone please help me how to pass the image from mainactivity to fullimageactivty through intent please find the below code


MainActivity


import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

public class MainActivity extends ActionBarActivity {

@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

GridView gridView = (GridView) findViewById(R.id.gridView1_bir);

gridView.setAdapter(new ImageListAdapter(MainActivity.this, eatFoodyImages));

gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {


Intent intent = new Intent(MainActivity.this,FullImage.class);
intent.putExtra("imgPos",eatFoodyImages.toString());
MainActivity.this.startActivity(intent);

}
});
}

public static String[] eatFoodyImages = {
"http://getapk.in/wp-content/gallery...obile-wallpaper-1080x1920-3326-1675210846.jpg",
"http://getapk.in/wp-content/gallery/car-wallpaper/mini-cooper-hd-wallpaper-for-android.PNG",
"http://getapk.in/wp-content/gallery...lpaper-for-android-devices-www.getapk.in_.jpg",
"http://getapk.in/wp-content/gallery/car-wallpaper/lykan_hypersport_sports_car-HD.jpg",
"http://getapk.in/wp-content/gallery...lpaper-for-android-devices-www.getapk.in_.jpg",
"http://getapk.in/wp-content/gallery/car-wallpaper/iphone-4-Audi-androif-car-wallapapers-full-hd.jpg",
"http://getapk.in/wp-content/gallery/car-wallpaper/iphone-6s-wallpaper-HD-1388dabrd-1080x1920.jpg",
"http://i.imgur.com/aC9OjaM.jpg",
"http://i.imgur.com/76Jfv9b.jpg",
"http://i.imgur.com/fUX7EIB.jpg",
"http://i.imgur.com/syELajx.jpg",
"http://i.imgur.com/COzBnru.jpg",
"http://i.imgur.com/Z3QjilA.jpg",
"http://getapk.in/wp-content/gallery...lpaper-for-android-devices-www.getapk.in_.jpg",
"http://getapk.in/wp-content/gallery/car-wallpaper/car-hd-wallperep.jpeg",
"http://i.imgur.com/aC9OjaM.jpg",
"http://i.imgur.com/76Jfv9b.jpg",
"http://i.imgur.com/fUX7EIB.jpg",
"http://i.imgur.com/syELajx.jpg",
"http://i.imgur.com/COzBnru.jpg",
"http://i.imgur.com/Z3QjilA.jpg",
"http://getapk.in/wp-content/gallery...obile-wallpaper-1080x1920-3326-1675210846.jpg",
"http://getapk.in/wp-content/gallery/car-wallpaper/mini-cooper-hd-wallpaper-for-android.PNG",
"http://getapk.in/wp-content/gallery...lpaper-for-android-devices-www.getapk.in_.jpg",
"http://getapk.in/wp-content/gallery/car-wallpaper/lykan_hypersport_sports_car-HD.jpg",
"http://getapk.in/wp-content/gallery...lpaper-for-android-devices-www.getapk.in_.jpg",
"http://getapk.in/wp-content/gallery/car-wallpaper/iphone-4-Audi-androif-car-wallapapers-full-hd.jpg",
"http://getapk.in/wp-content/gallery/car-wallpaper/iphone-6s-wallpaper-HD-1388dabrd-1080x1920.jpg"

};
}


FullImageActivity


import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;

/**
* Created by admin on 20-1-17.
*/
public class FullImage extends Activity {

@override
protected void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);
setContentView(R.layout.full_image);

//int position = getIntent().getExtras().getInt("imgPos");
ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
imageView.setImageResource(Integer.parseInt(MainActivity.eatFoodyImages.toString()));

}
}
 
Back
Top Bottom