gpt4 book ai didi

android - ListView 中的 RelativeLayout

转载 作者:行者123 更新时间:2023-11-30 02:43:15 25 4
gpt4 key购买 nike

我计划在我的应用程序中添加一个 Activity ,以在 ListView 中显示大量信息。是否可以将 RelativeLayouts 用作 ListView 元素?我添加了一张图片来向您展示我的意思。 enter image description here

最佳答案

是的,你可以。

在列表的适配器中:

public class MyAdapter extends BaseAdapter {

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (vi==null) {
vi = inflater.inflate(R.layout.my_list_elem, null);
vholder = new ViewHolder(vi, position);
vi.setTag(vholder);
}
......
}
}

和列表元素布局(my_list_elem.xml):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:chd="http://schemas.android.com/apk/res/com.marketingvici.profix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp" >

< your staff here >

</RelativeLayout>

关于android - ListView 中的 RelativeLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25465928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com