use handle in textView [closed]

0

I'm creating a chatbot and I want it when I send something, it appears in a textview the message 'thinking ...' for 5 seconds before sending the answer, I've already studied Handler, but so far I have not had any idea how do that, anybody have any ideas out there?

    
asked by anonymous 17.10.2018 / 23:00

1 answer

0

As no code has been put in to analyze, it follows a generic template so you can quickly adapt your reality:

import android.os.Bundle;
import android.os.Handler;

public class MinhaClasse extends AppCompatActivity implements Runnable{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tela_minha_tela);

//insira o código aqui que será execultado antes dos 5 segundos


Handler handler = new Handler(); //classe para contagem de tempo
handler.postDelayed(this, 5000); //5000 = 5 segundos

}

@Override
    public void run() {
//Aqui ficará o código que será executado após 5 segundos 

}
}
    
18.10.2018 / 02:44