首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

添加ddHeaderView注意有关问题

2012-08-28 
添加ddHeaderView注意问题?xml version1.0 encodingutf-8??LinearLayout ?xmlns:androidhttp:/

添加ddHeaderView注意问题

<?xml version="1.0" encoding="utf-8"?>?
<LinearLayout ?xmlns:android="http://schemas.android.com/apk/res/android"?
? ? android:layout_width="fill_parent"

android:id=“@+id=header”?
??? android:layout_height="fill_parent" >?
? ? <Button ?
? ? ? ? android:id="@+id/testButton"?
? ? ? ? android:layout_width="fill_parent" ?
? ? ? ? android:layout_height="wrap_content"?
? ? ? ? android:text="Income" ?
? ? ? ? android:textSize="15dip"?
? ? ? ? android:layout_weight="1" />?
</LinearLayout>?
上面是head.xml

你如果ListView lv = getListView();?
lv.addHeaderView(findViewById(R.layout.header));?就错了

通常ListView lv = getListView();?
LayoutInflater inflater = getLayoutInflater();?
ViewGroup header = (ViewGroup)inflater.inflate(R.layout.header, lv, false);?
lv.addHeaderView(header, null, false);?

热点排行