0

i have one question.i have one textview and one String and i try to show this text in texview(i can show it).but i have one option: for example ,i have String "Android example".i want to settext my texview each Letters runtime A An And and etc

String text = "Android example";
    char[] chartext = new char[text.length()];

    for (int i = 0; i < chartext.length; i++) {

        StringBuffer sb = new StringBuffer();

        sb.append(text);
        try {
            Thread.sleep(20);
            txt.setText(sb.toString());
        } catch (InterruptedException e) {

            e.printStackTrace();
        }

    }

i wrote some code but i can show string in textview but i have not recive same as result such as i told. how i can solve my problem if anyone knows solution please help me

Himanshu Agarwal
  • 4,623
  • 5
  • 35
  • 49
BekaKK
  • 2,173
  • 6
  • 42
  • 80
  • That should get you what you want. The problem is you are sleeping on the UI thread which is almost(?) never wanted. – codeMagic Sep 04 '14 at 14:35
  • how i can solved my problem? did you understand my problem ? – BekaKK Sep 04 '14 at 14:39
  • If I did understand correctly, then that link (and many other posts on SO) should give you what you want. Did you look at the link yet? – codeMagic Sep 04 '14 at 14:43
  • i try to recive like this result (http://stackoverflow.com/questions/6700374/android-character-by-character-display-text-animation) – BekaKK Sep 04 '14 at 14:47
  • You are doing nothing like that. That link and the one this is closed as use a `Handler` and `postDelayed()` not sleeping on the UI Thread in a `for loop`. Go back through those examples. – codeMagic Sep 04 '14 at 14:49
  • in your option if i 'll use Handler instead of thread problem solved ? – BekaKK Sep 04 '14 at 14:53

0 Answers0