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

android杂记

时间:2016-07-10 18:09:07      阅读:206      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!