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

1 Answers1

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
  • 780
  • 1
  • 6
  • 21
  • 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