Firing diffrent listener

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

  1. Leela krishna

    Leela krishna Member
    35

    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 New Member
    5

    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...