SeeOrderView.java 1.97 KB
package com.lijinji.part.widget;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lijinji.part.R;

public class SeeOrderView extends LinearLayout {

    boolean show = true;
    TextView see_title, see_text;

    public SeeOrderView(Context context) {
        super(context);
        initView(context);
    }

    public SeeOrderView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public SeeOrderView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    private void initView(Context context) {
       View view =  LayoutInflater.from(context).inflate(R.layout.layout_see_order, this);
       LinearLayout see_layout = view.findViewById(R.id.see_layout);
       final ImageView see_image = view.findViewById(R.id.see_image);
       see_title = view.findViewById(R.id.see_title);
       final LinearLayout see_linear = view.findViewById(R.id.see_linear);
       see_text = view.findViewById(R.id.see_text);
       see_layout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
               if(show) {
                   show = false;
                   see_linear.setVisibility(View.GONE);
                   see_image.setImageResource(R.mipmap.pull_down);
               } else {
                   show = true;
                   see_linear.setVisibility(View.VISIBLE);
                   see_image.setImageResource(R.mipmap.pull_top);
               }
            }
        });
    }

    public void setSeeTitle(String str) {
        see_title.setText(str);
    }

    public void setSeeMessage(String str) {
        see_text.setText(str);
    }
}