How to get the id of a view that I just added to a layout ..? (Android)

0

After:

    TextView iv = new TextView(this);
    iv.setText("Letrasletras");
    //Este es el ID
    int id=100+1;
    //Aqui se asigna el ID
    iv.setId(id);

    ElLayout.addView(iv);

Exactly in what way can I use the "findViewById" (or the equivalent) with that new element ..?

If they have another suggestion, it is welcome, the objective is to create an element (of the type "View") and be able to interact with it.

Thanks = D

For a simpler example

Suppose you need to do this:

private TextView lblMilisegundos;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    lblMilisegundos = (TextView) findViewById(R.id.lblMilisegundos);

}

But, "private TextView lblMiliseconds" (or the TextView in the xml), has not yet been written, it will "exist", at the moment you write this:

 ElLayout.addView(iv);
    
asked by want_code_that 19.06.2018 в 01:41
source

0 answers