I want to wait loop until I press a button(addBTN) to put values in array in every iteration of loop in android java

Viewed 22

My code:

for (int row = 0; row < noOfRowsFirst; row++) {
    for (int col = 0; col < noOfColsFirst; col++) {
        binding.valuesET.setHint("Enter Value at C" + row + col + ".");
        int finalRow = row;
        int finalCol = col;
        binding.addBTN.setOnClickListener(v -> {
                    // here loop should stop until I 
                    //click on addBTN and get value 
                    //from text view and put it in 
                    //array.
            matA[finalRow][finalCol] = Integer.parseInt(binding.valuesET.getText().toString().trim());
        });
        Toast.makeText(this, "Loop 1", Toast.LENGTH_SHORT).show();
    }
    Toast.makeText(this, "Loop 2", Toast.LENGTH_LONG).show();
}

Please help me to solve this problem. I am trying to make matrix solver app, in above code I am trying to put value in matrix array.

0 Answers
Related