dileber android 框架:乁( ˙Ω˙ )厂 跳转链接 dileber android框架
怎么说呢?既然看到了就在github上star一下呗 (´ཀ`」 ∠)
fragment中设置监听器
dileber框架中的BaseFragment有一个监听器如下
protected OnBaseInteractionListener mBaseListener;
public interface OnBaseInteractionListener {
void onRightButtonString(String str, View.OnClickListener onClickListener);
void onTitleName(String title);
}
protected void setActivityRightButton(String str,View.OnClickListener onClickListener) {
if (mBaseListener != null) {
mBaseListener.onRightButtonString(str,onClickListener);
}
}
protected void setActivityTitle(String title){
if (mBaseListener != null) {
mBaseListener.onTitleName(title);
}
}
@Override
public void onDetach() {
super.onDetach();
mBaseListener = null;
}
该监听器的作用是
设置activity的title bar菜单按钮文字,和点击效果。
设置activity title
让activity 实现OnBaseInteractionListener接口
并在fragment中设置
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnBaseInteractionListener) {
mBaseListener = (OnBaseInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnBaseInteractionListener");
}
}
在fragment 中调用
setActivityRightButton("创建", new View.OnClickListener() {
@Override
public void onClick(View v) {
mPresenter.createSaleChance(s_theme.getText().toString(),myaccount,s_product,d,stage_goal
,possibility_of_success,priority,remark.getText().toString());
}
});
如图效果