last day (14 days later) » 

2:27 PM
0
A: Android how to display image in Arraylist which intent from another activity?

Aslam Hossinwhy not you using the below procedure Pass Data like this : ArrayList<String> selectedItems = new ArrayList<String>(); intent.putExtra("selectedItems ", selectedItems ); Get data like this ArrayList<String> myList = (ArrayList<String>) getIntent().getSerializableExtra("selectedItems ");

 
ken
I tried before but I got warning from the IDE.
I update the question @aslam can u take a look?
 
This is working solution. Only problem is it will show "unchecked cast problem" but it will work. This is not major problem .
 
ken
but when I run in emulator,I still not display my photo back.Do you know what is the problem?
 
@SuppressWarnings("unchecked") add this line for removing those.
 
ken
ya..it removed,but the image still cant display,I just dont know what is the problem
I cant add this line ArrayList<String> selectedItems = new ArrayList<String>(); cause I get the value from another class like this ArrayList<String> selectedItems = imageAdapter.getCheckedItems();,I update the question ady
 
2:27 PM
Your are passing data MultiPhotoSelectActivity to PreuploadActivity but receiving in MultiPhotoSelectActivity. Can be a problem .
 
ken
I receive it at PreuploadActivity onActivityResult()
ArrayList<String> selectedItems = imageAdapter.getCheckedItems(); this is the value from another class
 
Can you sahre your whole activity class
then i can be clear
 
ken
sure
package com.example.raidshou.messenglass.activity;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
this is the multiphotoselectactivity
public class PreuploadActivity extends AppCompatActivity {
EditText inputStatus;
ImageButton addPhoto;
Button btnUpload;
Button btnCancel;
Bitmap bitmap;
LinearLayout linearMain;
ProgressDialog progressDialog;

boolean imageExisted;

int PICK_IMAGE_REQUEST = 111;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preupload);


inputStatus = (EditText)findViewById(R.id.inputStatus);
addPhoto = (ImageButton)findViewById(R.id.addPhoto);
this is the PreuploadActivity
So now I just cant display the photo in the arrayList in the PreuploadActivity class
thanks for your help bro
thanks for your time
bro if u spot any problem please let me know ya
 
are set image into imageview
 
ken
//Setting image to ImageView
ImageView imageView = new ImageView(getApplicationContext());
LinearLayout.LayoutParams layoutParams =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
imageView.setLayoutParams(layoutParams);
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
imageView.setPadding(0, 0, 0, 10);
imageView.setAdjustViewBounds(true);
imageView.setImageBitmap(bitmap);

linearMain.addView(imageView);
is it this bunch of code?
I just imageView.setImageBitmap(bitmap);
is it any problem here??
 
2:39 PM
No whare you set image into your imageview
?
 
ken
I set the imageView to a linearLayout
for (String selectedItem : selectedItems) {

Uri filePath = Uri.parse(selectedItem);


try {
// bimatp factory
BitmapFactory.Options options = new BitmapFactory.Options();

options.inSampleSize = 8;

bitmap = BitmapFactory.decodeFile(filePath.getPath(),
options);


//Setting image to ImageView
ImageView imageView = new ImageView(getApplicationContext());
LinearLayout.LayoutParams layoutParams =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
here is the code that I set the imageView
linearMain is a linear Layout
is it any problem in the BitmapFactory??
 
You add imageview into linearlayout but set image into bitmap .
 
ken
imageView.setImageBitmap(bitmap);
linearMain.addView(imageView);
is it like this??
is this a problem?
 
Why not you use normal imageview ?
It can be a problem
Just use normal imageview and set image using Glide or Picasso
 
ken
Cause I need to display multiple image
thats why i use LinearLayout
so normal ImageView can done too??
 
2:46 PM
You have to decodeResource into BitmapFactory
Are you decode multiple image into bitmap
 
ken
i do it in a for loop
i do it like this for (String selectedItem : selectedItems) {
 
Ok . I will review your code again . If i can get any solution then i nock you
 
ken
ok thanks bro
really appreciate
 
ok Brother.
 
ken
cause I really dont know what is the problem
any solution or lead me to the right direction will very appreciate
thanks once again
 
2:54 PM
Ok, brother . I am watching again your code. If i get any solution then i will be happy too .
No need to be giving thanks again please .
 

last day (14 days later) »