自定义列表视图与TextView的,TextView的,RadioGroup中的机器人 [英] Customized Listview with TextView,TextView,RadioGroup in android

查看:165
本文介绍了自定义列表视图与TextView的,TextView的,RadioGroup中的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发与列表视图为学生Marklist创作。

I'm developing an application with Listview for Student Marklist creation.

在这个应用中,名单有10名学生。有供其进行这些学生的考试四个等级。一个学生可以从四个适应唯一一个档次。

In this application, the List have 10 students. There are four grades provided for the exam which was conducted to those Students. One student can adapt only one grade from the four.

老师会在列表视图

我的XML文件Studentlist.xml是如下,..

My xml file Studentlist.xml is as follow,..

<?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文件如下,......

and my row.xml file is as follow,...

<?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"
        style="@style/text"
        android:layout_width="40dp"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/StudNo"
        style="@style/text"
        android:layout_width="80dp"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/StudName"
        style="@style/text"
        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>

现在我试图在... ...的形式输出

Now i'm trying for the output in the form of...

1 0001 AAAA&LT; RadioButton1&GT; &LT; RadioButton2&GT; &LT; RadioButton3&GT; &LT; RadioButton4&GT;

2 0002 BBBB&LT; RadioButton1&GT; &LT; RadioButton2&GT; &LT; RadioButton3&GT; &LT; RadioButton4&GT;

我如何使用适配器的功能。

How can i use the Adapter functionalities..

ArrayAdapter&LT;字符串,字符串,字符串,RadiGroup&GT; studList =新的ArrayAdapter&LT;字符串,字符串,字符串,RadiGroup&GT;();

我可以使用这个样子,以及如何开发自定义的适配器为的ListView ..

Can i use like this, and how to develop the customized Adapter for the ListView..

建议我最好的解决方案..!

Suggest me for the Best solution..!

推荐答案

您可以使用一个类从ArrayAdapter继承,并重写它的getView()方法。

You can use a class inheriting from ArrayAdapter, and overriding its getView() method.

public class StudentAdapter extends ArrayAdapter<Student> {

protected LayoutInflater inflater;

    public StudentAdapter(final Context context) {
        super(context, 0);
        inflater = (LayoutInflater) ((Context) context)
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public View getView(int position, View convertView, ViewGroup parent) {

        // Note: You should optimize here with re-using convertView

        View rowView = inflater.inflate(R.layout.user_address_row_layout,
                parent, false);
        TextView sNo = (TextView) rowView.findViewById(R.id.sNo);
        sNo.setText(getItem(position).number);
            // same for every field of the row
            // ...

        return rowView;
    }

 }

这篇关于自定义列表视图与TextView的,TextView的,RadioGroup中的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆