|
@@ -2,6 +2,7 @@ package com.sheep.jiuyan.samllsheep.utils;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
import android.graphics.drawable.ColorDrawable;
|
|
import android.graphics.drawable.ColorDrawable;
|
|
|
|
|
+import android.support.annotation.DrawableRes;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.Button;
|
|
import android.widget.Button;
|
|
|
import android.widget.ImageButton;
|
|
import android.widget.ImageButton;
|
|
@@ -206,7 +207,7 @@ public class TitleBarUtils {
|
|
|
* @param backgroundImgResId 设置背景的ResID,为零透明,-1不变,-2为Gone,其它是资源
|
|
* @param backgroundImgResId 设置背景的ResID,为零透明,-1不变,-2为Gone,其它是资源
|
|
|
* @param onClickListener 点击时的操作。
|
|
* @param onClickListener 点击时的操作。
|
|
|
*/
|
|
*/
|
|
|
- public void setRightImgBotton(Activity activity, int backgroundImgResId, View.OnClickListener onClickListener) {
|
|
|
|
|
|
|
+ public TitleBarUtils setRightImgBotton(Activity activity, int backgroundImgResId, View.OnClickListener onClickListener) {
|
|
|
Button button = activity.findViewById(R.id.btn_baseactivity_right);
|
|
Button button = activity.findViewById(R.id.btn_baseactivity_right);
|
|
|
ImageButton imageButton = activity.findViewById(R.id.ibtn_baseactivity_right);
|
|
ImageButton imageButton = activity.findViewById(R.id.ibtn_baseactivity_right);
|
|
|
if(button != null)
|
|
if(button != null)
|
|
@@ -216,13 +217,14 @@ public class TitleBarUtils {
|
|
|
imageButton.setImageDrawable(new ColorDrawable(0x00000000));
|
|
imageButton.setImageDrawable(new ColorDrawable(0x00000000));
|
|
|
} else if (backgroundImgResId == -2) {
|
|
} else if (backgroundImgResId == -2) {
|
|
|
imageButton.setVisibility(View.GONE);
|
|
imageButton.setVisibility(View.GONE);
|
|
|
- return;
|
|
|
|
|
|
|
+ return this;
|
|
|
} else if (backgroundImgResId != -1) {
|
|
} else if (backgroundImgResId != -1) {
|
|
|
imageButton.setImageResource(backgroundImgResId);
|
|
imageButton.setImageResource(backgroundImgResId);
|
|
|
}
|
|
}
|
|
|
if (onClickListener != null) {
|
|
if (onClickListener != null) {
|
|
|
imageButton.setOnClickListener(onClickListener);
|
|
imageButton.setOnClickListener(onClickListener);
|
|
|
}
|
|
}
|
|
|
|
|
+ return this;
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* 设置最右边的普通按钮状态
|
|
* 设置最右边的普通按钮状态
|
|
@@ -346,19 +348,15 @@ public class TitleBarUtils {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 右边两个按钮的情况
|
|
|
|
|
|
|
+ * 设置 从右边数,第两个按钮
|
|
|
*/
|
|
*/
|
|
|
- public TitleBarUtils setShowRightTwoBtn(Activity activity, int oneRes, int secondeRes, View.OnClickListener oneOnclick, View.OnClickListener twoOnclick){
|
|
|
|
|
- ImageButton ibtn_two_right = activity.findViewById(R.id.ibtn_two_right);
|
|
|
|
|
- ImageButton ibtn_baseactivity_right = activity.findViewById(R.id.ibtn_baseactivity_right);
|
|
|
|
|
|
|
+ public TitleBarUtils setRightSecondBtn(Activity activity, @DrawableRes int secondRes, View.OnClickListener secondOnclick){
|
|
|
|
|
+ ImageButton secondImageButton = activity.findViewById(R.id.ibtn_two_right);
|
|
|
|
|
|
|
|
- ibtn_two_right.setVisibility(View.VISIBLE);
|
|
|
|
|
- ibtn_baseactivity_right.setVisibility(View.VISIBLE);
|
|
|
|
|
- ibtn_two_right.setImageResource(secondeRes);
|
|
|
|
|
- ibtn_baseactivity_right.setImageResource(oneRes);
|
|
|
|
|
|
|
+ secondImageButton.setVisibility(View.VISIBLE);
|
|
|
|
|
+ secondImageButton.setImageResource(secondRes);
|
|
|
|
|
|
|
|
- ibtn_two_right.setOnClickListener(twoOnclick);
|
|
|
|
|
- ibtn_baseactivity_right.setOnClickListener(oneOnclick);
|
|
|
|
|
- return mTitleBarUtils;
|
|
|
|
|
|
|
+ secondImageButton.setOnClickListener(secondOnclick);
|
|
|
|
|
+ return this;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|