Independent action in loop Android - Stack Overflow

How to run an action in a loop in Android . I tried this code but it is not what i need, I need to call

How to run an action in a loop in Android . I tried this code but it is not what i need, I need to call a function in which with help of TTS a word must be spoken and then loop to the next word until to the end of string array. my code:

        playButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(minusButton.isEnabled()){
                minusButton.setEnabled(false);
            }

            if(plusButton.isEnabled()){
                plusButton.setEnabled(false);
            }

            new Thread() {
                @Override
                public void run() {

                    do {
                            speakText();

                    }
                    while (i <= myTextCharater.length);

                }
            }.start();
        }
    });

Function code:

    private void speakText(){
    String str = myTextCharater[i];
    tts.setSpeechRate(Float.parseFloat(speedSpeakFinal + "f"));
    tts.speak(str, TextToSpeech.QUEUE_ADD, null, null);

    i++;

}

The problem is that it loops to the end end only last word is pronounced.

Each spoken word must change its color during pronouncing and back.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745645911a4637971.html

相关推荐

  • Independent action in loop Android - Stack Overflow

    How to run an action in a loop in Android . I tried this code but it is not what i need, I need to call

    22天前
    70

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信