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

Apps Firing diffrent listener

Discussion in 'Android Development' started by Leela krishna, Sep 10, 2009.

  1. Leela krishna

    Leela krishna Newbie
    Thread Starter
    Rank:
    None
    Points:
    35
    Posts:
    10
    Joined:
    Sep 8, 2009

    Sep 8, 2009
    10
    0
    35
    i have created 4 buttons and listeners
    then if i press one button it fires another button,s listener
    help me
     

    Advertisement

  2. jksharma

    jksharma Lurker
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Oct 15, 2009

    Oct 15, 2009
    4
    0
    5
    Make one listener class implementing OnClickListener and set this listener to all buttons and then in OnClick(View v) implement all logic performed on click event.

    you can get reference of resource id of button by
    v.getId()
    then compare it to all buttons

    if(v.getId()==R.id.button1)

    then write logic which you want to perform when button1 is clicked.
    make sure all buttons have different ids by layout xml.
     

Share This Page

Loading...