How to findviewbyid 100 EditTex in a TableLayout - android

I have put 100 edittext objects in a tablelayout,how could I use findviewbyid to find those editext objects ? so I could get the text from those edittext whcih user have entered ?

You can keep an ArrayList to hold the EditText like
ArrayList<EditText> editTextArray=new ArrayList<EditText>();
And add each EditText
editTextArray.add(editText1);
So , you can invoke as follows
editTextArray.get(i).getText();

Related

EditText scroll to last text line

So I have an EditText with fixed size that is most likely to contain a long text with multiple lines.
When the view doesn't have focus I want to scroll to the top of it. Managed to do that using view.scrollBy(0,0) inside it's setOnFocusChangeListener when hasFocus is false.
But I also want to scroll down to the last line of the EditText when hasFocus is true. Is there a way to get some valid int values to pass in the view.scrollBy(x,y) based on the last text line inside the view?
If your EditText has focus then you could go with
editText.setSelection(editText.text.length) //place the cursor at the end of the text
which should automatically scroll down to the end of the editText
Check it out if it will work
EditText editText = (EditText) findViewById(R.id.edtText);
editText.setSelection(editText.getText().length());

How to generate multiple layout and get value of each filed in it in android

Actually i am going on with the page which has a add button if the user click add button it
should generate multiple layoutwith DropDown and edittext tried it programatically how can i take each value of dropDown
and edittext from all layout and pass it.
(for eg: if user click the button for 10 times it should generate 10 layout with the fields but the their is no limit for click).
If any other approach please help me out to solve this issue.
Tried:
LinearLayout linearLayout = (LinearLayout)getActivity().findViewById(R.id.progm_view);
EditText editText = new EditText(this);
editText.setId(i);
editText.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
linearLayout.addView(editText);
int i = edittext.getId();
editText.setTag("data");
EditText ed = (EditText)findViewByTag("data");
String text = ed.getText().toString();
Have an xml with dropdown and edittexts. Whenever user clicks, inflate the layout and add to the parent layout, so that you can user getChildAt(position) method to get each inflated layout so as to get the dropdown and edittext objects.

Can we have a part of a scrollable Listview (implemented using hashmap) non-scrollable?

Im using textview and edittexts to make a listview and using a hashmap to copy paste the layout. Now how do i get the values from the edit texts ? I tried it but it doesn't work because everytime we're using a new hashmap variable to create a copy and i didn't find anything like an array of hashmap variables.. Help needed.
My xml files :
MarksList>res>layout>marks_list_main :
Suppose you have added a LinearLayout as list item and on that Layout there is an edittext and a textview
LinearLayout layout=(LinearLayout) listView.getItemAtPosition(0);
EditText text = (EditText) layout.getChildAt(0); //Assuming you added EditText first
String s=text.getText().toString()

how to dynamically display the EditText?

i'm new to android. So can any one help me to get the following, when i enter the number in a EditText, the entered no.of EdidText should be appear dynamically. For example if i entered 3 in a EditText then, 3 EditText(no.of) have to be shown on the screen. How can i show this?
You need to add a TextWatcher to your EditText by calling EditText.addTextChangedListener(). Then in your TextWatcher wait for calls to afterTextChanged and count the characters and update your title. This will be easier if you make your Activity implement the the TextWatcher interface itself.
Add layout to your xml where you want to display the Edittext.
Then create the Layout variable e.g
LinearLayout ll = (LinearLayout)findViewById(R.id...);
and create new textboxes and add to the linearlayout e.g
EditText[] edit = new EditText[]();
EditText[] edit= new EditText[entered number];
initialize the variables in the loop by new Edittext(context);
and add each one to the Layout
`ll.addView(edit[iterator]);`

Cannot type anythig into the editText field that is inside listview(that is edittext field is the cell of the listview)

hii
I have a listview and each cell of a listview contain an edittext field.But the problem is i can't type anything into the editText field.I there any solution ?
EditText fields may be disabled due to layout_width and layout_height done for EditTexts and ListView.

Categories

Resources