1. Download our Official Android App: Forums for Android!

Apps change image on click!!

Discussion in 'Android Development' started by wounded, Aug 19, 2012.

  1. wounded

    wounded Member
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    35
    Joined:
    Jul 27, 2012

    Jul 27, 2012
    35
    0
    15
    hi all ,
    hope all are fine
    i want to change image to another image or video by click ??!
    anybody know to help plz
     

    Advertisement

  2. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    Code (Text):
    1.  
    2.  
    3. make your class implement View.OnClickListener, then override the following method as so.
    4. @Override
    5. public void onClick(View v) {
    6.  
    7.     if (v == myButton)
    8.         imageView.setImageResource(R.drawable.my_resource);
    9. }
    10.  
     
  3. wounded

    wounded Member
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    35
    Joined:
    Jul 27, 2012

    Jul 27, 2012
    35
    0
    15
    yeah ,thank you
     

Share This Page

Loading...