Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to send images form an Activity to another Activity?
    primarykey
    data
    text
    <p>I am trying to make an App that have 2 <code>Activities</code>. <code>Activity1</code> is a gallery can call <code>Activity2</code>. <code>Activity2</code> is a camera app that capture images then send these images to <code>Activity1</code> and <code>Activity1</code> will show these images in gallery.I can't send images between two <code>Activities</code>.</p> <p>This code is my gallery in <code>Activity1</code>. I know <code>SerializebleBitmap</code> but in my code how can I put it in the gallery list? Here is my code:</p> <pre><code>public class HelloGallery extends Activity { private Gallery gallery; private ImageView imgView; private Button btn; private static final int SHOW_SUB_FORM = 0; private String[] imglist; Bundle extras = getIntent().getExtras(); private Integer[] mImageIds = { R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7 }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); gallery = (Gallery) findViewById(R.id.gallery); gallery.setAdapter(new ImageAdapter(this)); imgView = (ImageView)findViewById(R.id.ImageView01); imgView.setImageResource(mImageIds[0]); btn = (Button) findViewById(R.id.Takept); btn.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { btn_onClick(); } }); if (extras != null){ String[] imglist= extras.getStringArray("IMAGE_LIST"); imgView.setImageResource(mImageIds[0]); } gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { Toast.makeText(HelloGallery.this, "" + position, Toast.LENGTH_SHORT).show(); imgView.setImageResource(mImageIds[position]); } }); }; private void btn_onClick() { Intent intent = new Intent(HelloGallery.this,CameraDemo.class); startActivity(intent); } public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; private Context mContext; public ImageAdapter(Context c) { mContext = c; TypedArray attr = mContext.obtainStyledAttributes(R.styleable.HelloGallery); mGalleryItemBackground = attr.getResourceId( R.styleable.HelloGallery_android_galleryItemBackground, 0); attr.recycle(); } public int getCount() { return mImageIds.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(mContext); imageView.setImageResource(mImageIds[position]); imageView.setLayoutParams(new Gallery.LayoutParams(100, 100)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setBackgroundResource(mGalleryItemBackground); return imageView; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload