0

I have 270 EditTexts. Now I want to get the value from each EditText and put it into a String[] concurrently and compare it for results. Unfortunately I can't do it. How can I achieve it?

One more thing I want to check if correct or not. If not correct I just get this correct answer in EditText which is wrong.

3
  • if edit text box in one layout then get all child for (int i = 0; i < ll_projList_projectType.getChildCount(); i++) { if(ll_projList_projectType.getChildAt(i) instanceof EditText) { EditText edt = (EditText)ll_projList_projectType.getChildAt(i); str[i] = edt.getText().toString() } } Commented Aug 28, 2015 at 12:09
  • what is ll_projList_projectType? Commented Aug 28, 2015 at 12:14
  • This is layout which contain edit text box Commented Aug 28, 2015 at 12:55

1 Answer 1

2

The idea is that you have to iterate over all your EditText boxes and save its result in the string[]. To do this I recommend you to have this 270 EditText boxes inside a ViewGroup and then iterate over the childs of the ViewGroup. You can do something like this:

LinearLayout layout = (LinearLayout)findViewById(R.id.layout); // The ViewGroup mentioned which should have the 270 EditText boxes inside
String[] myStringArray = iterateOverViews(layout);

Where iterateOverViews(layout) calls to this function:

public String[] iterateOverLayout(LinearLayout layout) {
    String[] ret = new String[270];
    for (int i = 0; i < 270; i++) {
        EditText box = layout.getChildAt(i);
        ret[i] = box.getText();
    }
    return ret;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.