请帮我解决一个问题。我知道如何向ListView中添加项 (LItem := ListView.Items.Add),但是如何添加头部和尾部呢?我使用的是DELPHI XE5,不是JAVA。
请帮我解决一个问题。我知道如何向ListView中添加项 (LItem := ListView.Items.Add),但是如何添加头部和尾部呢?我使用的是DELPHI XE5,不是JAVA。
LItem := ListView.Items.Add; LItem.Purpose:=TListItemPurpose.Footer;
这段代码是向ListView控件中添加一个新的项,并将其设置为页脚(Footer)。我之前也遇到过这个问题。在我的组件中,我想要在Listview中添加下拉刷新的功能。我的做法是在xml布局文件中声明视图布局,在我的ListView子类中使用以下代码:
this.addHeaderView(headerRelativeLayout, null, false); //this is the ListView sub class
这是我的整个代码:
private void init(Context context) {
inflater = LayoutInflater.from(context);
headerRelativeLayout = (RelativeLayout)inflate(context, R.layout.refresh_header_view, null);
arrowImage = (ImageView)headerRelativeLayout.findViewById(R.id.head_arrowImageView);
progressBar = (ProgressBar)headerRelativeLayout.findViewById(R.id.head_progressBar);
headerTextView = (TextView)headerRelativeLayout.findViewById(R.id.head_tipsTextView);
lastUpdateDateTextView = (TextView)headerRelativeLayout.findViewById(R.id.head_lastUpdatedDateTextView);
headerRelativeLayout.setPadding(0, -1 * HEADER_HEIGHT, 0, 0);
this.addHeaderView(headerRelativeLayout, null, false);
}
更多细节可以查看这个链接: Android ListView下拉刷新示例
试一下这个
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom|top"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/background_bottom_bar"
>
<TextView
android:text="Header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<GridView
android:id="@+id/gridview_practioner"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:columnWidth="90dp"
android:horizontalSpacing="10dp"
android:numColumns="5"
android:layout_weight="1"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:text="Footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/background_bottom_bar"
android:layout_gravity="bottom"/>
</LinearLayout>
</LinearLayout>