A
A
AlexHolms2016-11-11 20:39:00
Java
AlexHolms, 2016-11-11 20:39:00

How to display a GridLayout with filled cells?

When the button is clicked, an event is fired that creates a GridLayout with the dimensions entered by the user and fills it with EditTexts. But nothing happens.
Maybe this is because the page has a root LinearLayout that also defines various elements and the created GridLayout should be placed after them? Then tell me how to implement this.
Tried googling but couldn't find a similar problem.
I am attaching the code.

public class ActionsWithMatricesActivity extends AppCompatActivity
    {
        GridLayout MatrixA;
        @Override
        protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_actions_with_matrices);
        }
     
        public void OutputMatrix (View view)  //Создание матриц
        {
            MatrixA = new GridLayout(this);  //Создание матрицы А
            //Получение строк
            EditText strEditText = (EditText) findViewById(R.id.editTextAstr);
            Integer strA = Integer.valueOf(strEditText.getText().toString());
            //Получение столбцов
            EditText stlEditText = (EditText) findViewById(R.id.editTextAstl);
            Integer stlA = Integer.valueOf(stlEditText.getText().toString());
     
            MatrixA.setColumnCount(stlA);
            MatrixA.setRowCount(strA);
     
            EditText CellET = new EditText(this);
            MatrixA.addView(CellET);   
        }
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question