• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Need help to program a list interface

Jgjio

Lurker
Hello, I'm having a hard time understanding how to program a list interface. I'm trying to come up with actionable steps to accomplish this task.


The List Interface GUI Requirements
  • A Vertical list of EditTexts.
  • List starts with one EditText box, opon entering in valid input (a number) a new EditText appears.
  • Opon entering in the editText it automatically focuses on the new EditText.
I'm pretty sure I need a listener for onfocus and entering, however, I don't know how to create a listener for new text boxes that I created dynamically...? This is my first Android project.
 
How far have you got with this? I'm assuming you have nothing, so your steps would be:-

1. Define the layout for your UI. Pretty simple, as it contains just one EditText in a vertical LinearLayout
2. Add a TextWatcher to the EditText
3. Understand how to add UI components to a layout dynamically. Many web examples like this:
http://stackoverflow.com/questions/...view-to-a-linearlayout-dynamically-in-android
4, Call requestFocus() on your EditText to grab the focus.
 
Thank you for responding!
Does step 2 mean that I'm adding a listener? My issue is after I dynamically create the new EditText, I want my listener to listen to the new EditText. Having never even made a listener before, I'm confused about if I can even do that.
 
Thank you!

I should have mentioned that I plan on having hundreds of EditTexts, do you know of a way to add text change listeners to them without implementing them one by one?
 
Yes having multiple listeners would be very unmanageable. Here's a solution creating a custom listener class:

http://stackoverflow.com/questions/5702771/how-to-use-single-textwatcher-for-multiple-edittexts

As someone pointed out, this not technically one TextWatcher for all EditTexts, as it creates many instances of the GenericTextWatcher class at runtime. But for your purposes it limits the amount of code you need to write. Check the comments for an alternative solution, which creates only one TextWatcher object at runtime. If your UI contains many hundreds of EditTexts, then you may probably need to look at this solution, which is here:

http://stackoverflow.com/questions/4283062/textwatcher-for-more-than-one-edittext/13787221#13787221
 
I will be implementing the proposed solution in the next two weeks and I'll update this thread with my progress or questions along the way. Thanks for taking time out of your day to help me! It is very appreciated!
 
Back
Top Bottom