• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris

EditText in array

Ranch Hand
Posts: 36
Android Java ME
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wanted to put EditText in array.So that it can be printed several time.I don't want to make several EditText in XML i really wanted to avoid making robust xml.
I planned to make one EditText and then with loop displaying several time.
I did that with text but don't know how to do with EditText.
It should look like this:

Text    Edit text
Text    Edit text
Text    Edit text
Text    Edit text
Text    Edit text

I know for ArrayList and ArrayAdapter but i must make two more class and at the end it's the same like i made several EditTexts in XML... I want to shorten the code writing.I tried everything that i know i lost a day in something that should be an easy task....

my XML:

nad my JAVA:
Posts: 1868
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are a couple of thoughts:

Have you looked into creating a custom view? Here are a couple of tutorials on how this can be done:
  • https://developer.android.com/guide/topics/ui/custom-components
  • http://www.vogella.com/tutorials/AndroidCustomViews/article.html
  • Maybe with a custom view you will not need to create a array of views.

    You stated that you do not want to have an overly robust xml file.
    Have you looked into dynamically adding and remove views as explained in these tutorials:
  • https://www.androidtutorialpoint.com/basics/dynamically-add-and-remove-views-in-android/
  • https://android--code.blogspot.com/2018/02/android-kotlin-create-view.html
    Always look on the bright side of life. At least this ad is really tiny:
    The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
      Bookmark Topic Watch Topic
    • New Topic