How to create a dynamic layout of equations system on android

Asked

Viewed 40 times

0

I’m creating an application for Android that solves systems of linear equations in which the user defines the number of equations, and generates a system of Equations, where the user needs to define only the constants, as this example:
1: Imagem

2: Imagem2 or 3: Imagem3 And implement a button that retrieves what was typed.

I tried to use the Library implementation 'com.github.frhnfrq:MathView:1.1' https://github.com/frhnfrq/MathView and the Tablelayout

Android

public class MainActivity extends AppCompatActivity {

private EditText ordemt;
private int ordem;
private TableLayout tabela;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ordemt = findViewById(R.id.ordemid);
    tabela = findViewById(R.id.tabelaid);


}


public void Gerar(View view) {

    ordem = Integer.parseInt(ordemt.getText().toString());
    tabela.removeAllViews();


    for (int i = 0; i < ordem; i++) {

        TableRow tr = new TableRow(this);

        int contador = 1;
        for (int j = 0; j < ordem; j++) {

            if (j % 2 == 0) {
                EditText et = new EditText(this);
                tr.addView(et);

            } else {
                MathView mv = new MathView(getApplicationContext());

                mv.setText("$ x_" + contador + " + $");
                mv.setTextSize(20);
              mv.setPixelScaleType(MathView.Scale.SCALE_DP);
                tr.addView(mv);
                contador++;
            }

        }

        tabela.addView(tr);
    }


}

public void Recuperar(View view) {

}
//Como pegar valores dos EditText gerados dinamicamente no código java 

}

So doubtful how I get Edittext values created Dynamically, how to put edges and improve layout https://imgur.com/i8VAnxr where it got too far apart //

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT
    );
     mv.setLayoutParams(params); 

This code snippet didn’t work in Mathview Object

  • Your questions have nothing to do with that particular application. You should do them separately and in focus. All that code only causes noise. One of your questions is answered by the indicated duplicate.

  • Thank you, The code was more to give an introduction of what I’m trying to develop, where I don’t know of any library that exists for such purpose or implement the methods, the solution you flagged is not working in Mathview, I edited the question as I implemented

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.