开发者

Approach for changing edittext to dropdowns at runtime?

开发者 https://www.devze.com 2023-02-17 10:59 出处:网络
what would be a good approach for the following? EditText EditText EditText the above three edit texts are how I have my xml layout. Depending on the users settings up on the server.. these edittext

what would be a good approach for the following?

EditText

EditText

EditText

the above three edit texts are how I have my xml layout. Depending on the users settings up on the server.. these edittexts need to be changed to a dropdown.

so for dropdowns if field1 is false field2 is true and field3 is false it would look like

EditText

DropDown

EditText

Should I

  1. do it all programatically at runtime,

    removing existing views from xml and putting an开发者_运维问答 empty ViewGroup in its place

  2. have both options for each field in xml, and only show valid one (seems inefficient)
  3. some other approach I havent thought of


I might use ViewStubs. The view isn't inflated until you do it. You would have 6 ViewStubs but only 3 would get inflated at RunTime.


you can put both edittext and dropdown on a FrameLayout, with edit text being in front. then, on edit activation or any other logic - you can switch them... same thing can be done with ViewFlipper, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消