use Handle in textView

Asked

Viewed 31 times

0

I am creating a chatbot and I want that when I send something, appear in a textview the message 'thinking...' for 5 seconds before sending the answer, I have studied about Handler, but so far I have no idea how to do this, someone has some idea out there?

  • 1

    Could you show us the relevant part of your code so far? This facilitates our analysis and increases the possibility of you getting help. See here

1 answer

0


Since no code has been placed for us to analyze, follow a generic model 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 

}
}

Browser other questions tagged

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