1. Are you ready for the Galaxy S20? Here is everything we know so far!

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

    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
     


  2. jonbonazza

    jonbonazza Android Expert

    Not directly, but you can create your own Button subclass that has an EditText built-in
     
  3. JiMMaR

    JiMMaR Android Enthusiast

    can't you put them over each other and make 'em disappear/reappear on click ?
     
  4. jonbonazza

    jonbonazza Android Expert

    You cant detect the input on the buttons if there is an EditText on top.
     
  5. jonbonazza

    jonbonazza Android Expert

    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

    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

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

Share This Page

Loading...