首先建一个自定义View的类
继承LinearLayout
选用前2个方法
package com.bawei.mnks;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
/*
*@Auther:赵敏如
*@Date: 2019年
*@Time:
*@Description:
-
*/public class Xjj extends LinearLayout {
private ImageView titleimg;
private TextView title;public Xjj(Context context) {
super(context);
}public Xjj(Context context, AttributeSet attrs) {
super(context, attrs);
View inflate = LayoutInflater.from(context).inflate(R.layout.tp, this);
titleimg = inflate.findViewById(R.id.titleimg);
title = inflate.findViewById(R.id.title);
titleimg.setOnClickListener(new OnClickL