insert edittext between two other edittexts with inflater
I am t开发者_开发技巧otally new to android and programming, and you have helped me a ton so far. I have hit another roadblock,however. (sure there are many more to come)
I am adding edittexts dynamically with the layoutinflator to a vertical linearlayout.
When i select an edittext in the middle and hit the button to inflate another edittext, I need to know how to insert the new edittext directly below the one that is selected, pushing the rest down, instead of adding it after the last one added.
Thanks in advance for your valuable time, Chris
LinearLayout has an addView(View view, int index) method which you can use to put new view into it at specific position.
A simple solution would be to have a empty LinearLayout between the two, to where you inflate.
This is if you only have 2.
If it's really dynamic go with @compostus answer.
精彩评论