更轻松地重命名片段中的所有TextView?

时间:2015-06-23 21:01:11

标签: java android android-fragments

我目前有一个片段,里面有一堆卡片。我正在尝试使用包含“ScheduleEntry”实例的ArrayList中的数据,找到一种更简单的方法来重命名每张卡内的每个textview。任何建议表示赞赏!

XML布局

http://pastebin.com/B8Nn9ZV0

Java Fragment

http://pastebin.com/a9LiSuDw

ScheduleEntry.java

    package club.spiralsolutions.witsmobile;

    public class ScheduleEntry {
    public int getPeriod() {
        return period;
    }

    public void setPeriod(int period) {
        this.period = period;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    public String getTeacher() {
        return teacher;
    }

    public void setTeacher(String teacher) {
        this.teacher = teacher;
    }

    public String getRoom() {
        return room;
    }

    public void setRoom(String room) {
        this.room = room;
    }

    public int getAverage() {
        return average;
    }

    public void setAverage(int average) {
        this.average = average;
    }

    private int period;
    private String name;
    private int ID;
    private String teacher;
    private String room;
    private int average;

    public ScheduleEntry()
    {

    }

    public ScheduleEntry(int period, String name, int ID, String teacher, String room, int average)
    {
        this.period = period;
        this.name = name;
        this.ID = ID;
        this.teacher = teacher;
        this.room = room;
        this.average = average;
    }
    public ScheduleEntry(int period, String name, int ID, String teacher, String room)
    {
        this.period = period;
        this.name = name;
        this.ID = ID;
        this.teacher = teacher;
        this.room = room;

    }

}

1 个答案:

答案 0 :(得分:0)

您应该创建卡片视图列表,您可以使用v7支持库中的RecyclerView,这是Android开发者网站提供的一个很棒的培训教程:

https://developer.android.com/training/material/lists-cards.html