我得到了「只有創建視圖層次結構的原始線程才能觸及其視圖。」因爲我在使用「onUtteranceCompleted」時使用了文本到語音轉換,並在內部對TextView進行了一些調用。文本到語音轉換時出錯:「只有創建視圖層次結構的原始線程可以觸摸其視圖。」
下面是我的一些代碼:
public class MyActivity extends Activity implements OnInitListener, OnUtteranceCompletedListener {
private TextView txtCurrentWord;
public void onCreate(Bundle savedInstanceState) {
...
this.txtCurrentWord = (TextView) findViewById(R.id.txtCurrentWord);
}
public void onUtteranceCompleted(String uttId) {
this.txtCurrentWord.setText("hello world");
}
}
會有人知道如何避免這個錯誤嗎?
謝謝
發現嘗試txtCurrentWord.setText( 「世界你好」);沒有'這個'。 – Urban 2012-02-19 22:03:45
不會出現同樣的錯誤:( – xtrimsky 2012-02-19 22:33:34