在Android中使用TextView,TextView,RadioGroup自定义ListView

在Android中使用TextView,TextView,RadioGroup自定义ListView,第1张

概述我正在使用ListView开发用于创建学生Marklist的应用程序.在此应用程序中,列表有10个学生.为这些学生提供的考试分为四个等级.一个学生只能适应四个年级中的一个.教师将在ListView中为学生分配成绩.我的xml文件Studentlist.xml如下:<?xmlversion="1.0"encoding="utf-8"?><Lin

我正在使用ListVIEw开发用于创建学生MarkList的应用程序.

在此应用程序中,列表有10个学生.为这些学生提供的考试分为四个等级.一个学生只能适应四个年级中的一个.

教师将在ListVIEw中为学生分配成绩.

我的xml文件StudentList.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" ><ListVIEw    androID:ID="@+ID/ListVIEw1"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content" ></ListVIEw></linearLayout>

我的row.xml文件如下:

<?xml version="1.0" enCoding="utf-8"?><tableLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="500dp"androID:layout_height="fill_parent"androID:padding="10dp" ><tableRow>    <TextVIEw        androID:ID="@+ID/SNo"                androID:layout_wIDth="40dp"        androID:layout_height="wrap_content" />    <TextVIEw        androID:ID="@+ID/StudNo"                androID:layout_wIDth="80dp"        androID:layout_height="wrap_content" />    <TextVIEw        androID:ID="@+ID/Stud@R_419_6889@"                androID:layout_wIDth="180dp"        androID:layout_height="wrap_content" />    <RadioGroup        androID:ID="@+ID/radioGroup1"        androID:layout_wIDth="160dp"        androID:layout_height="wrap_content"        androID:orIEntation="horizontal" >        <Radiobutton            androID:ID="@+ID/radio0"            androID:layout_wIDth="40dp"            androID:layout_height="wrap_content"            androID:checked="true" />        <Radiobutton            androID:ID="@+ID/radio1"            androID:layout_wIDth="40dp"            androID:layout_height="wrap_content" />        <Radiobutton            androID:ID="@+ID/radio2"            androID:layout_wIDth="40dp"            androID:layout_height="wrap_content" />        <Radiobutton            androID:ID="@+ID/radio3"            androID:layout_wIDth="40dp"            androID:layout_height="wrap_content" />    </RadioGroup></tableRow>

现在我正在尝试以以下形式输出:

1 0001 AAAA <Radiobutton1> <Radiobutton2> <Radiobutton3> <Radiobutton4>2 0002 BBBB <Radiobutton1> <Radiobutton2> <Radiobutton3> <Radiobutton4>

如何使用适配器功能?

ArrayAdapter&LT字符串,字符串,字符串,RadiGroup&GT studList = new ArrayAdapter< String,String,String,RadiGroup>();

我可以这样使用,以及如何为ListVIEw开发定制的适配器吗?

建议我最好的解决方案!

解决方法:

这是用于ListvIEw的自定义适配器的示例示例.根据需要进行修改:
XML布局:

<?xml version="1.0" enCoding="utf-8"?><linearLayout androID:ID="@+ID/main"    androID:orIEntation="vertical"    androID:layout_height="fill_parent"    androID:layout_wIDth="fill_parent" xmlns:androID="http://schemas.androID.com/apk/res/androID">    <!-- header -->    <linearLayout        androID:ID="@+ID/header"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:background="@color/black" >        <TextVIEw            androID:ID="@+ID/item2"            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:height="30dip"            androID:text="Latest News - Your Healing Place"            androID:textAppearance="?androID:attr/textAppearanceMedium"            androID:textcolor="#FFFFFF"            androID:wIDth="100dip" />        <TextVIEw            androID:ID="@+ID/item1"            androID:layout_wIDth="wrap_content"            androID:layout_height="fill_parent"            androID:height="30dip"            androID:wIDth="20dip" />    </linearLayout>    <VIEw androID:layout_wIDth="fill_parent"        androID:layout_height="1dip"        androID:background="?androID:attr/ListdivIDer" />    <linearLayout androID:ID="@+ID/layout"        androID:layout_wIDth="wrap_content"        androID:layout_height="fill_parent">        <ListVIEw            androID:ID="@+ID/ListvIEw"            androID:layout_wIDth="fill_parent"            androID:layout_height="fill_parent"            androID:background="@color/black" >        </ListVIEw>    </linearLayout></linearLayout>

news.java:

List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();String[] from = new String[] {"details", "date"};int[] to = new int[] { R.ID.item1, R.ID.item2};ListVIEw lv= (ListVIEw)findVIEwByID(R.ID.ListvIEw);HashMap<String, String> map = new HashMap<String, String>();map.put("details", "This is a sample message");map.put("date", "24-07-2003");fillMaps.add(map);SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.grID_item, from, to);lv.setAdapter(adapter);
总结

以上是内存溢出为你收集整理的在Android中使用TextView,TextView,RadioGroup自定义ListView全部内容,希望文章能够帮你解决在Android中使用TextView,TextView,RadioGroup自定义ListView所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1094612.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存