Listview 片段中的CustomList适配器

Listview 片段中的CustomList适配器,listview,android-fragments,baseadapter,custom-lists,Listview,Android Fragments,Baseadapter,Custom Lists,我正在尝试在我的应用程序片段中生成警报列表。但我无法让它工作。我已经阅读了许多关于自定义列表视图生成的文章,但无法找出适配器的错误。 下面是我的片段 public class AlarmListFragment extends MainFragment { private ListView listViewAlarmList; private ImageButton addAlarm; private DBHandler dbObj;

我正在尝试在我的应用程序片段中生成警报列表。但我无法让它工作。我已经阅读了许多关于自定义列表视图生成的文章,但无法找出适配器的错误。 下面是我的片段

    public class AlarmListFragment extends MainFragment {
        private ListView listViewAlarmList;
        private ImageButton addAlarm;
        private DBHandler dbObj;
        private Alarm alarmCounter;
    List<FinalAlarms> finalAlarmses = new ArrayList<FinalAlarms>();
    public AlarmListFragment(){}

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState){
        View rootView = inflater.inflate(R.layout.fragment_home_alarm,container,false);
        listViewAlarmList = (ListView)rootView.findViewById(R.id.listViewAlarms);
        addAlarm = (ImageButton)rootView.findViewById(R.id.imageButtonAddAlarm);




    return rootView;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
            finalAlarmses.add(new FinalAlarms(){{
                this.setAlarm_title("pattoki");
                this.setTimeFromString("16:08");

            }});
            finalAlarmses.add(new FinalAlarms(){{
                this.setAlarm_title("Lahore");
                this.setTimeFromString("18:10");

            }});

    FinalAlarmAdaptor finalAlarmAdaptor = new     FinalAlarmAdaptor(getActivity(),finalAlarmses);
        listViewAlarmList.setAdapter(finalAlarmAdaptor);

    }
下面是我的适配器类

    public class FinalAlarmAdaptor extends BaseAdapter {

    LayoutInflater inflater;
    List<FinalAlarms> alarm;

    public FinalAlarmAdaptor(Activity context, List<FinalAlarms> items) {
        super();
        this.alarm = items;
        this.inflater = (LayoutInflater) context.
                getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    }

    public int getCount() {
        return alarm.size();
    }

    public Object getItem(int position) {
        return alarm.get(position);
    }

    public long getItemId(int position) {

        return 0;
    }

    private class Holder{
        TextView title,time,date;
        ToggleButton mon,tue, wed, thu, fri,sat,sun;
        ToggleButton isOff;
        ImageButton isShared;
    }

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

        FinalAlarms item = alarm.get(position);
        Holder holder;
        View vi = convertView;

        if (convertView == null) {
            holder = new Holder();
            vi = inflater.inflate(R.layout.customlist_row_reschedule_alarm, null);
            holder.title = (TextView) vi.findViewById(R.id.textViewHomeTitle);
            holder.time = (TextView) vi.findViewById(R.id.textViewHomeTime);
            holder.date = (TextView)vi.findViewById(R.id.textViewHomeDate);
            holder.mon = (ToggleButton) vi.findViewById(R.id.toggleBtnMon);
            holder.tue = (ToggleButton) vi.findViewById(R.id.toggleBtnTues);
            holder.wed = (ToggleButton) vi.findViewById(R.id.toggleBtnWed);
            holder.thu  = (ToggleButton) vi.findViewById(R.id.toggleBtnThu);
            holder.fri = (ToggleButton) vi.findViewById(R.id.toggleBtnFri);
            holder.sat = (ToggleButton) vi.findViewById(R.id.toggleBtnSat);
            holder.sun = (ToggleButton) vi.findViewById(R.id.toggleBtnSun);

            holder.isOff = (ToggleButton)vi.findViewById(R.id.toggleButtonHomeIsOff);
            holder.isShared = (ImageButton)vi.findViewById(R.id.imageButtonHomeIsShared);
            vi.setTag(holder);
        }else{
            holder = (Holder)vi.getTag();
        }

        holder.title.setText(item.getAlarm_title());

                holder.time.setText(item.getTime().getHours()+":"+item.getTime().getMinute());

        if(item.getWeek().isMon()) {
            holder.mon.setChecked(true);

        }
        if(item.getWeek().isTues()){
            holder.tue.setChecked(true);
        }
        if(item.getWeek().isWed()){
            holder.wed.setChecked(true);
        }

        if(item.getWeek().isThu()){
            holder.thu.setChecked(true);
        }

        if(item.getWeek().isFri()){
            holder.fri.setChecked(true);
        }

        if(item.getWeek().isSat()){
            holder.sat.setChecked(true);
        }

        if(item.getWeek().isSun()){
            holder.sun.setChecked(true);
        }


        holder.isOff.setChecked(true);

        return vi;


    }


    }
列表的RowItem的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"

    >
   <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/reschedule_final_alarm_bg"
    android:paddingTop="10dp"
    android:paddingBottom="10dp"
     android:layout_marginTop="20dp"
      >
      <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"



            >
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:orientation="vertical"
                >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textViewHomeTitle"
                android:text="Good Morning"
                android:textColor="@color/white"
                android:layout_marginTop="10dp"
                android:textSize="20sp"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textViewHomeTime"
                android:textColor="@color/white"
                android:text="6:00 AM"
                android:textSize="23sp"
                />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/white"
                    android:text="@string/dummyDate"
                    android:id="@+id/textViewHomeDate"
                    android:textSize="20sp"
                    />
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    android:orientation="horizontal"
    >
    <ToggleButton
        android:layout_width="30dp"
        android:layout_height="25dp"
        android:text="Mon"
        android:id="@+id/toggleBtnMon"
        android:textColor="@color/white"
        android:textOff=""
        android:textOn=""
        android:background="@drawable/popup_repeat_days_toggle_mon_selector"

        />
    <ToggleButton
        android:layout_width="30dp"
        android:layout_height="25dp"
        android:id="@+id/toggleBtnTues"
        android:text="Tues"
        android:layout_marginLeft="5dp"
        android:textColor="@color/white"
        android:textOff=""
        android:textOn=""
        android:background="@drawable/popup_repeat_days_toggle_tues_selector"
        />
    <ToggleButton
        android:layout_width="30dp"
        android:layout_height="25dp"
        android:id="@+id/toggleBtnWed"
        android:text="Wed"
        android:layout_marginLeft="5dp"
        android:textColor="@color/white"
        android:textOff=""
        android:textOn=""
        android:background="@drawable/popup_repeat_days_toggle_wed_selector"
        />
        <ToggleButton
        android:layout_width="30dp"
        android:layout_height="25dp"
        android:id="@+id/toggleBtnThu"
        android:text="Thu"
        android:layout_marginLeft="5dp"
        android:textColor="@color/white"
        android:textOff=""
        android:textOn=""
        android:background="@drawable/popup_repeat_days_toggle_thu_selector"
        />
       <ToggleButton
        android:layout_width="30dp"
        android:layout_height="25dp"
        android:id="@+id/toggleBtnFri"
        android:text="Fri"
        android:layout_marginLeft="5dp"
        android:textColor="@color/white"
        android:textOn=""
        android:textOff=""
        android:background="@drawable/popup_repeat_days_toggle_fri_selector"
        />
       <ToggleButton
        android:layout_width="30dp"
        android:layout_height="25dp"
        android:id="@+id/toggleBtnSat"
        android:text="Sat"
        android:layout_marginLeft="5dp"
        android:textColor="@color/white"
        android:textOff=""
        android:textOn=""
        android:background="@drawable/popup_repeat_days_toggle_sat_selector"
        />
      <ToggleButton
        android:layout_width="30dp"
        android:layout_height="25dp"
        android:id="@+id/toggleBtnSun"
        android:text="Sun"
        android:layout_marginLeft="5dp"
        android:textColor="@color/white"
        android:textOn=""
        android:textOff=""
        android:background="@drawable/popup_repeat_days_toggle_sun_selector"
        />

      </LinearLayout>

            </LinearLayout>
            </RelativeLayout>


        </LinearLayout>
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginLeft="20dp"
        android:src="@drawable/reschedule_line_final_alarm"
        />
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:orientation="vertical"
        >
        <ToggleButton
            android:id="@+id/toggleButtonHomeIsOff"
            android:layout_width="wrap_content"
            android:layout_height="22dp"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="19dp"
            android:background="@drawable/reschedule_toggle_button_selector"
            android:textOff=""
            android:textOn=""/>
        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:padding="15dp"
            android:layout_marginLeft="37dp"
            android:layout_marginBottom="10dp"
            android:background="@drawable/reschedule_button_selector"
            android:id="@+id/imageButtonHomeIsShared"
            android:src="@drawable/share_selector"/>
    </LinearLayout>
    </LinearLayout>
    </LinearLayout>

我发现了问题所在。它是固定的