I need to add some fields (textview, edit and checkbox) dynamically to a tablelayout on focus change of edittext which is already present and visible. I need to validate the text scanned and if validated need to populate the views below for user to scan....
Could please suggest a good way to go about this? I have written the onfocus change validation logic.. but unable to manipulate the tablelayout within focus change
Many thanks in advance.
Related
I'm trying to make a contact app which can create contacts and add it to the phone default database. Now the question I came across is, how can I add more text fields for the user to enter more numbers?
I was thinking about using defined fields (like in android contacts) and on creating of the view, show user only one text field and hide all the others. So the user can add more fields by the 'add' button next to the view.
Then the problem is, how to align them properly under the first text field if the user wants to use the third text field instead of the second.
I checked this in SO Android: Adding multiple Views to a Linear Layout dynamically but I need different IDs to getText from different textViews.
Is there a way to do this thing I want to do? Thanks in advance :)
I have some 8 text boxes(edit text) in my layout. How do I add them as a group instead of adding them individually.
I want to take input from user in those textboxes(edit text). Input is related, so I need a group of textboxes. Checked the documentation but didn't find.
Any way to add such textboxes as a group?
You can use EditTexts in a Layout (typically a LinearLayout or a RelativeLayout will do).
That container will act as a group.
I'm fooling around with Android and trying to make a simple application to split a bill between friends.
I'm wondering if there is a way to create buttons and textfields based on user input. For example, if the user says he needs to split the bill 5 ways, how can I generate 5 buttons and 5 textfields? Similarly, splitting 10 ways will create 10 buttons and 10 text fields.
Thanks,
Ben
Edit: I should mention I have implemented the input already. I simply need to use the input to generate the buttons and textfields.
What you need is to create a Linear layout that have only a button and textfield then you can dynamically add that layout into your activity main's layout programatically. You can follow this thread on how to add view dynamically to another view
I've had a similar problem. You need to make a custom layout and then use LayoutInflater to "put it into another layout".You can use the return of inflater.inflate() to get the parent layout. then you just use parent.getChildAt(i) in a for loop for all "fields" and getChildAt(whatever the index of the button or text field you want is) to get the buttons and access them programatically. You can also give every Button a unique ID with setId(generateViewId(yourButton)) to access them from other functions.
I have vector of EditTexts that I'm dynamically generating and dynamically adding addTextChangedListeners.
The issue is that the returned Editable on "afterTextChanged" doesn't let me know which EditText this listener is associated with.
Is there a way to call the respective EditText from within the TextWatcher?
Thanks,
I would suggest creating your own TextWatcher but before I put down my untested pseudo-code here, I discovered there's another guy named Sebastian Roth who had already done that.
Check out his answer:
TextWatcher for more than one EditText
What I am trying to achieve is the following:
Save A Field In A TableRow To A database When It Loses Focus. I can not use a listView as I have 68 Rows containing over 200 fields on the TableLayout.
So what I am asking is, Is there a Generic way that I can check which field on the TableLayout has just lost focus with 1 onFocusChangeListener?
Thanks
Steve
You could add all the EditText-fields you want to monitor to one single onChangeListener.
It's onFocusChange()-method supplies the View that has gained/lost focus so you can get the displayed text and it supplies the hasFocus-boolean, which can be used to determine if the focus was lost or not.