码迷,mamicode.com
首页 > 移动开发 > 详细

Android为textView设置setText的时候报错

时间:2015-04-04 10:46:22      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:textview

一、我的代码如下:就是我textView设置值

if (list != null) {
    for (Student stu : list) {
        //如果一下子赋值的话是不正确的
        tv_name.setText(stu.getName());
        tv_sex.setText(stu.getSex());
        tv_age.setText(stu.getAge());

    }
}

报出错误:

04-04 08:56:33.950: W/ResourceType(23332): No package identifier when getting value for resource number 0x0000000c
04-04 08:56:33.950: D/AndroidRuntime(23332): Shutting down VM
04-04 08:56:33.950: W/dalvikvm(23332): threadid=1: thread exiting with uncaught exception (group=0x416ddd58)
04-04 08:56:33.960: E/AndroidRuntime(23332): FATAL EXCEPTION: main
04-04 08:56:33.960: E/AndroidRuntime(23332): Process: com.xuliugen.studentsytem, PID: 23332
04-04 08:56:33.960: E/AndroidRuntime(23332): android.content.res.Resources$NotFoundException: String resource ID #0xc
android.content.res.Resources.getText(Resources.java:252)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at android.content.res.MiuiResources.getText(MiuiResources.java:107)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at android.widget.TextView.setText(TextView.java:3895)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at com.xuliugen.ui.activity.StudentManagerActivity$1.onClick(StudentManagerActivity.java:82)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at android.view.View.performClick(View.java:4444)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at android.view.View$PerformClick.run(View.java:18457)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at android.os.Handler.handleCallback(Handler.java:733)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at android.os.Handler.dispatchMessage(Handler.java:95)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at android.os.Looper.loop(Looper.java:136)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at android.app.ActivityThread.main(ActivityThread.java:5034)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at java.lang.reflect.Method.invokeNative(Native Method)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at java.lang.reflect.Method.invoke(Method.java:515)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:807)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:623)
04-04 08:56:33.960: E/AndroidRuntime(23332):    at dalvik.system.NativeStart.main(Native Method)

技术分享

具体解决方法:

if (list != null) {
    for (Student stu : list) {
        //如果一下子赋值的话是不正确的
        tv_name.setText(stu.getName()+"");
        tv_sex.setText(stu.getSex()+"");
        tv_age.setText(stu.getAge()+"");                        
    }
}

Android为textView设置setText的时候报错

标签:textview

原文地址:http://blog.csdn.net/xlgen157387/article/details/44870843

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!