首页 > 移动平台 > 详细

android杂记

时间:2016-07-10 18:07:23      阅读:282      评论:0      收藏:0      [点我收藏+]

1、ArrayAdapter requires the resource ID to be a TextView问题

技术分享
listView.setAdapter(new ArrayAdapter<String>(
                this,R.layout.textlayout,
                strs
        ));
View Code

布局容易出现:ArrayAdapter requires the resource ID to be a TextView 报错

textlayout.xml:

技术分享
<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:layout_width="match_parent"  
    android:layout_height="match_parent"  
    android:orientation="vertical"  
     >  
        <TextView android:id="@+id/text1"    
         android:textSize="16sp"    
         android:textStyle="bold"    
         android:layout_width="fill_parent"    
         android:layout_height="wrap_content"/>    
  
</LinearLayout> 
View Code

问题出在:

技术分享
<?xml version="1.0" encoding="utf-8"?>  
<TextView   
         xmlns:android="http://schemas.android.com/apk/res/android"  
         android:id="@+id/text1"    
         android:textSize="16sp"    
         android:textStyle="bold"    
         android:layout_width="fill_parent"    
         android:layout_height="wrap_content"/> 
View Code

 

xmlns:android=http://schemas.android.com/apk/res/android 就是这句了....

添加到自己的TextView中就ok.

因为根节点必须是TextView

android杂记

原文:http://www.cnblogs.com/xtreme/p/5658243.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!