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

Apps How to make a image clickable and go to a new page

Discussion in 'Android Development' started by monaiz, Jul 1, 2011.

  1. monaiz

    monaiz Member
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    35
    Joined:
    Jun 11, 2011

    Jun 11, 2011
    35
    1
    16
    How do i make a image clickable and open a new page up?
     

    Advertisement

  2. El Presidente

    El Presidente Beware The Milky Pirate!
    Moderator
    Rank:
     #5
    Points:
    3,118
    Posts:
    31,701
    Joined:
    Jan 3, 2011

    Jan 3, 2011
    31,701
    23,286
    3,118
    Scotland
    On the forum?

    The code you need is below:

    [url=http://yoururl][img]Your Image URL[/img][/url]
     
  3. monaiz

    monaiz Member
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    35
    Joined:
    Jun 11, 2011

    Jun 11, 2011
    35
    1
    16
    ok im talking about android thats why im in APPLICATION DEVELOPMENT
     
  4. El Presidente

    El Presidente Beware The Milky Pirate!
    Moderator
    Rank:
     #5
    Points:
    3,118
    Posts:
    31,701
    Joined:
    Jan 3, 2011

    Jan 3, 2011
    31,701
    23,286
    3,118
    Scotland
    Sorry, you just didn't make it very clear.

    It's not unusual to find posts asking questions about forum stuff in random sub sections, hence my response.

    Hope you find your answer.
     
  5. cr5315

    cr5315 Android Enthusiast
    Rank:
    None
    Points:
    68
    Posts:
    434
    Joined:
    Jul 23, 2010

    Jul 23, 2010
    434
    158
    68
    Narnia
    In your XML, click on the button and in properties go to, Background. Have the image you want in your drawable folder(s). If the image has the text you want, go to Text in the properties tab and delete the default text or whatever you have there. Then in you activity, use this code.

    Code (Text):
    1. Button buttonName = (Button) findViewById(R.id.button_id);
    2.          buttonName.setOnClickListener(new View.OnClickListener() {
    3.              public void onClick(View v) {
    4.                  Intent MyIntent = new Intent (currentActivity.this, NewActivity.class);
    5.                  startActivity(MyIntent);
    6.              }
    7.          });
    You can replace these with what ever you want
    buttonName
    MyIntent

    Replace:
    currentActivity: The name of the activity that has the button
    NewActivity: The activity that is being launched
    R.id.button_id: The ID of the button

    You will need to import Button and Intent after you put that code in.

    Hope this helps
     
    CBarbas likes this.

Share This Page

Loading...