package com.example.leudaemialikeme.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Switch;

import com.example.leudaemialikeme.Adapter.AdapterClock;
import com.example.leudaemialikeme.R;


public class MdctRmdActivity extends BaseActivity {

    private ListView lv;
    private AdapterClock adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mdctrmd);

        ImageView back;
        back =findViewById(R.id.back_to_index);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(MdctRmdActivity.this, MainActivity.class);
                i.putExtra("flag",1);
                startActivity(i);
            }
        });

        lv=(ListView)findViewById(R.id.lv_list_data);
        adapter=new AdapterClock(MdctRmdActivity.this);


        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Switch aSwitch=adapter.getaSwitch(i);
                if(aSwitch.isChecked()){
                    aSwitch.setChecked(false);
                    //进行业务处理
                }else {
                    aSwitch.setChecked(true);
                    //进行业务处理
                }
            }
        });
    }

}

