天天看點

Android異常: android.content.res.Resources$NotFoundException: String resource ID #0x4d3b3d50

原來還記錄過這個問題,如今又犯,還是寫出來警醒一下;

異常資訊:android.content.res.Resources$NotFoundException: String resource ID #0x4d3b3d50

問題代碼:viewHolder.mTVTime.setText(news.getBehot_time());

解決方法:viewHolder.mTVTime.setText(String.valueOf(news.getBehot_time()));

綜述:setText()方法是不可以直接傳數字的,如果傳入int類型的話,會進入這個方法:

public final void setText(@StringRes int resid) {
        setText(getContext().getResources().getText(resid));
    }
           

它會認為你傳入的是資源id,例如layout布局中的android:text="@string/sn_news";

如果要傳數字可以像上面那樣,将int類型轉換一下;

-----------------------------------------------------------------------------------------------------------------------------------

類似問題參考:http://stackoverflow.com/questions/20177003/android-content-res-resourcesnotfoundexception-string-resource-id-0x0

繼續閱讀