|
|
@@ -0,0 +1,74 @@ |
|
|
|
package com.bonait.bnframework.modules.home.fragment.mode; |
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
import android.content.res.TypedArray; |
|
|
|
import android.graphics.Color; |
|
|
|
import android.util.AttributeSet; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.View; |
|
|
|
import android.view.ViewGroup; |
|
|
|
import android.widget.ImageView; |
|
|
|
import android.widget.LinearLayout; |
|
|
|
import android.widget.RelativeLayout; |
|
|
|
import android.widget.TextView; |
|
|
|
|
|
|
|
import androidx.annotation.Nullable; |
|
|
|
|
|
|
|
import com.bonait.bnframework.R; |
|
|
|
|
|
|
|
import butterknife.BindView; |
|
|
|
import butterknife.ButterKnife; |
|
|
|
|
|
|
|
public class ImageButtonControl extends LinearLayout { |
|
|
|
@BindView(R.id.caidan_image) |
|
|
|
ImageView image_u; |
|
|
|
@BindView(R.id.caidan_text) |
|
|
|
TextView text_u; |
|
|
|
@BindView(R.id.rea_main) |
|
|
|
RelativeLayout rea_main; |
|
|
|
private View root; |
|
|
|
private int ks_ys = R.mipmap.silos1; |
|
|
|
private int showbk=-9999; |
|
|
|
public ImageButtonControl(Context context, @Nullable AttributeSet attrs) { |
|
|
|
super(context, attrs); |
|
|
|
root= LayoutInflater.from(context).inflate(R.layout.imagebuttomcontrol, this); |
|
|
|
ButterKnife.bind(this, root); |
|
|
|
initParams(root.getContext(), attrs); |
|
|
|
Init(); |
|
|
|
} |
|
|
|
|
|
|
|
private void initParams(Context context, AttributeSet attrs) { |
|
|
|
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.caidan_control); |
|
|
|
if (typedArray != null) { |
|
|
|
try { |
|
|
|
ks_ys = typedArray.getResourceId(R.styleable.caidan_control_imagesrc, R.mipmap.silos1); |
|
|
|
showbk = typedArray.getInt(R.styleable.caidan_control_showbk, -9999); |
|
|
|
typedArray.recycle(); |
|
|
|
}catch (Exception exception) |
|
|
|
{ |
|
|
|
Log.i("错误", exception.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void Init() |
|
|
|
{ |
|
|
|
String str= this.getTag().toString(); |
|
|
|
if(!str.isEmpty()) |
|
|
|
{ |
|
|
|
text_u.setText(str); |
|
|
|
}else |
|
|
|
{ |
|
|
|
text_u.setText(""); |
|
|
|
} |
|
|
|
|
|
|
|
image_u.setImageResource(ks_ys); |
|
|
|
|
|
|
|
if(showbk!=-9999) |
|
|
|
{ |
|
|
|
rea_main.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |