0

I am beginner level in android. how to create multidimensional array in android at runtime.

i want to create multidimensional array of EditText box dynamically (at runtime) and all should be disables except the first one.

if any one knows about this please answer. examples will be appreciated.

this working ok..

TextView textView[][] = new TextView[2][2];

after this when i tried to assign data it throws nullpointor exception..

        for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            editText[i][j].setText("data");
        }
    }
7
  • 1
    "multidimensional array", you mean a Matrix of EditText? can you explain a little bit more what are you trying to get? Commented Jan 27, 2012 at 11:55
  • yes matrix of EditText. @SERPRO Commented Jan 27, 2012 at 11:57
  • i didnt understand... will you explain in more detail about the WEBVIEW idea..?????@BicycleDude Commented Jan 27, 2012 at 12:03
  • 2
    The idea of WebView I guess is to create what you are planning to do with HTML and Javascript and then just open that HTML inside a WebView. Am I right @BicycleDude? Commented Jan 27, 2012 at 12:10
  • can't we create matrix of EDITTEXT in andriod,....?????? Commented Jan 27, 2012 at 12:12

1 Answer 1

1

this is the code for multidimensional array of edittext and to display it as well as to disable it...

layout = new LinearLayout(this);
    layout.setOrientation(1);
    layout.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));

    EditText editText[][] = new EditText[2][2];

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            editText[i][j] = new EditText(this);
            editText[i][j].setText("1");
            editText[i][j].setWidth(50);
            layout.addView(editText[i][j]);
        }
    }
    for (int i = 1; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            // editText[i][j].setEnabled(false);
            editText[i][j].setClickable(false);
            editText[i][j].setEnabled(false);
        }
    }
    setContentView(layout);
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.