试图从日历DAY_OF_WEEK导致资源未找到 [英] Trying to get DAY_OF_WEEK from calendar causes Resource Not Found

查看:174
本文介绍了试图从日历DAY_OF_WEEK导致资源未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到一周中的一天:

I am trying to find the day of the week by:

Calendar cd = Calendar.getInstance();
int dow = cd.get(Calendar.DAY_OF_WEEK);

但每当我加载程序,我收到了

But whenever I load the program I get a

Unable to Start Activity android.content.res.Resources$NotFound Exception: String resource ID #0x5

和0x5的对应到今天周四,在日历资源,我认为。

And 0x5 corresponds to Thursday, today, in the Calendar resource I think.

我该如何解决这个问题呢?

How can I solve this problem?

推荐答案

我觉得你要更新视图与是不正确的int值(因为setText方法不超载对于int类型),您需要这样的字符串数组

I think you are trying to update view with that int value which is not true (because setText method isn't overloaded for int type), you need to make array of strings like that

private static final String[] WEEK = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

和使用

textView.setText(WEEK[cal.get(Calendar.DAY_OF_WEEK)]);

这篇关于试图从日历DAY_OF_WEEK导致资源未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆