package net.ddns.mahaljsp.ch14_01_fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

/**
 * Created by Administrator on 2016/12/7.
 */

public class FragmentA extends Fragment {
    View view;
    ImageView img1, img2, img3, img4, img5, img6;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view=inflater.inflate(R.layout.fragment_a, container, false);
        processViews();
        processControllers();
        return view;
    }
    public void processViews(){
        img1=(ImageView)view.findViewById(R.id.imageView1);
        img2=(ImageView)view.findViewById(R.id.imageView2);
        img3=(ImageView)view.findViewById(R.id.imageView3);
        img4=(ImageView)view.findViewById(R.id.imageView4);
        img5=(ImageView)view.findViewById(R.id.imageView5);
        img6=(ImageView)view.findViewById(R.id.imageView6);
    }
    public void processControllers(){
        img1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ((MainActivity)getActivity()).showPicture(R.drawable.img1);
            }
        });
        img2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ((MainActivity)getActivity()).showPicture(R.drawable.img2);
            }
        });
        img3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ((MainActivity)getActivity()).showPicture(R.drawable.img3);
            }
        });
        img4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ((MainActivity)getActivity()).showPicture(R.drawable.img4);
            }
        });
        img5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ((MainActivity)getActivity()).showPicture(R.drawable.img5);
            }
        });
        img6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ((MainActivity)getActivity()).showPicture(R.drawable.img6);
            }
        });
    }
}
