0

I have an array of string which contain image URL's and Text which i am showing in image view with text. here i want when user click imageview i want to get that image and will show in android activity.How can I do that

code:-

ImageView m_DealImage;String[] dealText = {"Install Medlife", "Install Voonik", "Install IndigoRummy","Install Chai point"};

String[] arr = new String[]{
        "http://media.vcommission.com/brand/files/vcm/3012/Medlife_CPS_MLVC2_336X280.jpg",
        "http://media.vcommission.com/brand/files/vcm/3156/Voonik_CPS_Half_Price_Fashion_Sale_728x90.jpg",
        "http://media.vcommission.com/brand/files/vcm/3144/IndigoRummy_CPA_starter_banus_100_728x90.gif"};

/*First Step*/
                        handler = new Handler();
                        Runnable runnable = new Runnable() {
                            int i =0;
                            @Override
                            public void run() {
                                Picasso.with(getApplicationContext()).load(arr[i]).into(m_DealImage);
                                m_ToolTip.setVisibility(View.VISIBLE);
                                m_DealText.setText(dealText[i]);
                                i++;
                                if (i > arr.length - 1) {
                                    i = 0;
                                }
                                m_DealImage.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        //  Didn't know where to go
                                    }
                                });
                                handler.postDelayed(this, 6000);
                            }
                        };
                        handler.postDelayed(runnable, 6000);
Ravi
  • 117
  • 1
  • 8
  • 2
    Pass the required url to next activity using Intent extras. Here's how you can do that http://stackoverflow.com/questions/5265913/how-to-use-putextra-and-getextra-for-string-data – Shashank Udupa Nov 17 '16 at 06:28

2 Answers2

0

i am not sure what your asking. If you want pass image data then refer code.

Send Activity

Intent _intent = new Intent(this, newscreen.class);
Bitmap _bitmap; // your bitmap
ByteArrayOutputStream _bs = new ByteArrayOutputStream();
_bitmap.compress(Bitmap.CompressFormat.PNG, 50, _bs);
i.putExtra("byteArray", _bs.toByteArray());
startActivity(i);

Receive Activity

if(getIntent().hasExtra("byteArray")) {
ImageView _imv= new ImageView(this);
Bitmap _bitmap = BitmapFactory.decodeByteArray(
        getIntent().getByteArrayExtra("byteArray"),0,getIntent().getByteArrayExtra("byteArray").length);        
_imv.setImageBitmap(_bitmap);
}
Arpit Patel
  • 9,047
  • 5
  • 60
  • 72
0

Store image variable static and get clicked position from String[] arr = new String[]{..}.just pass that clicked position to another activity and using getIntent() to get position and firstactivity.arr[pos] then you will get url.

Example: Activity 1: public static String[] arr = new String[]{..} Intent ->pass position(Clicked position) Activity 2: pos=getintent().getIntExtra(k,v);

now get url: Activity1.arr[pos];

Vadivel
  • 750
  • 1
  • 6
  • 19
  • public static String[] arr = new String[]{ "http://media.vcommission.com/brand/files/vcm/3012/Medlife_CPS_MLVC2_336X280.jpg", }; Picasso.with(getApplicationContext()).load(arr[0]).into(m_DealImage); m_DealImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(MainActivity.this,Main2Activity.class).putExtra("pos",1)); } }); – Vadivel Nov 17 '16 at 09:10
  • Activity2:imageView= (ImageView) findViewById(R.id.imageView); int pos=getIntent().getIntExtra("pos",1); Picasso.with(getApplicationContext()).load(MainActivity.arr[pos]).into(imageView); – Vadivel Nov 17 '16 at 09:11