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

Apps is there any way to put EditText on button

Discussion in 'Android Development' started by goldE, Sep 19, 2011.

  1. goldE

    goldE Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    5
    Joined:
    Sep 13, 2011

    Sep 13, 2011
    5
    0
    5
    hi

    i have 2 button's on my screen, i need that when i press button2

    the EditText will appear on the button1 and when i'll press button2

    again, the EditText will disappear.

    is there any way to do it on java for android ?



    thanks in advance
     

    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
    Not directly, but you can create your own Button subclass that has an EditText built-in
     
  3. JiMMaR

    JiMMaR Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    363
    Joined:
    Jun 12, 2010

    Jun 12, 2010
    363
    57
    53
    can't you put them over each other and make 'em disappear/reappear on click ?
     
  4. jonbonazza

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

    Jul 13, 2010
    1,930
    457
    163
    Male
    You cant detect the input on the buttons if there is an EditText on top.
     
  5. jonbonazza

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

    Jul 13, 2010
    1,930
    457
    163
    Male
    Now that I think about it. The best ting to do would be to subclass EditText and implement the OnClickListener Interface.
     
  6. JiMMaR

    JiMMaR Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    363
    Joined:
    Jun 12, 2010

    Jun 12, 2010
    363
    57
    53
    what about having the button and the edittext on the same position , and when one button is clicked , the other edittext would go into "gone" status and the button would show
    I don't see how this may not work
     
  7. jonbonazza

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

    Jul 13, 2010
    1,930
    457
    163
    Male
    Well, in this case, that would work I suppose, but it's really not the best method of doing things. There are only a handful of scenarios where "hiding" a control is considered good practice. This is what the enabled state is there for.
     

Share This Page

Loading...