我開始使用TextView的findViewWithTag()方法來動態更新文本,並在更新UI時遇到問題。該方法的作用在於它找到了TextView,並且我可以設置文本。我通過檢查代碼中的對象來驗證這一點。儘管該方法返回正確的TextView和文本屬性更新,但UI不會更新。所有代碼都在UI線程上執行,並且findViewById()方法按預期工作。我在這裏做錯了什麼?Android - findViewWithTag與findViewById
//This works as expected correctly
((TextView) findViewById(R.id.textview)).setText("NEW TEXT");
//This updates the test property, but does not update the UI.
((TextView) view.findViewWithTag("TAG TEXT")).setText("NEW TEXT");
這些方法在Activity的onCreate方法中進行了測試。
謝謝。
確保您不使用「標記文本」作爲標籤的另一個瀏覽 – Rami 2015-03-13 20:12:11