diff --git a/ZBLibrary/src/main/java/zuo/biao/library/base/BaseTabActivity.java b/ZBLibrary/src/main/java/zuo/biao/library/base/BaseTabActivity.java index 0454c2ab..4a4a82a8 100755 --- a/ZBLibrary/src/main/java/zuo/biao/library/base/BaseTabActivity.java +++ b/ZBLibrary/src/main/java/zuo/biao/library/base/BaseTabActivity.java @@ -286,7 +286,7 @@ public void initData() {//必须调用 //tab<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - topTabView = setTopBarLayout(context,0,setTabBarLayout()); + topTabView = newTopTabView(context, 0, getTopTabViewResId()); llBaseTabTabContainer.removeAllViews(); llBaseTabTabContainer.addView(topTabView.createView()); topTabView.setCurrentPosition(currentPosition); @@ -303,23 +303,20 @@ public void initData() {//必须调用 } - /* - * 如果需要自定义tab layout 需要实现此方法 - * - * */ - - public int setTabBarLayout(){ + /**如果需要自定义tab layout 需要实现此方法 + */ + public int getTopTabViewResId() { return R.layout.top_tab_view; } - /* - * - * TopTabView 构造函数中,第二个参数为最小宽度,可以默认传入0即可 - * */ - - @Override - public TopTabView setTopBarLayout(Activity context, int minWidth, int layoutId) { - return new TopTabView(context,0,layoutId); + /**TopTabView 构造函数 + * @param context + * @param minWidth 最小宽度,传入 0 表示默认值 + * @param layoutId + * @return + */ + public TopTabView newTopTabView(Activity context, int minWidth, int layoutId) { + return new TopTabView(context, 0, layoutId); } diff --git a/ZBLibrary/src/main/java/zuo/biao/library/base/BaseTabFragment.java b/ZBLibrary/src/main/java/zuo/biao/library/base/BaseTabFragment.java index ace5dc80..8a9ab93c 100755 --- a/ZBLibrary/src/main/java/zuo/biao/library/base/BaseTabFragment.java +++ b/ZBLibrary/src/main/java/zuo/biao/library/base/BaseTabFragment.java @@ -273,7 +273,7 @@ public void initData() {//必须调用 } } - topTabView = setTopBarLayout(context,0,setTabBarLayout()); + topTabView = newTopTabView(context, 0, getTopTabViewResId()); llBaseTabTabContainer.removeAllViews(); llBaseTabTabContainer.addView(topTabView.createView()); topTabView.setCurrentPosition(currentPosition); @@ -289,23 +289,20 @@ public void initData() {//必须调用 } - /* - * 如果需要自定义tab layout 需要实现此方法 - * - * */ - - public int setTabBarLayout(){ + /**如果需要自定义tab layout 需要实现此方法 + */ + public int getTopTabViewResId() { return R.layout.top_tab_view; } - /* - * - * TopTabView 构造函数中,第二个参数为最小宽度,可以默认传入0即可 - * */ - - @Override - public TopTabView setTopBarLayout(Activity context, int minWidth, int layoutId) { - return new TopTabView(context,0,layoutId); + /**TopTabView 构造函数 + * @param context + * @param minWidth 最小宽度,传入 0 表示默认值 + * @param layoutId + * @return + */ + public TopTabView newTopTabView(Activity context, int minWidth, int layoutId) { + return new TopTabView(context, 0, layoutId); } diff --git a/ZBLibrary/src/main/java/zuo/biao/library/interfaces/ViewPresenter.java b/ZBLibrary/src/main/java/zuo/biao/library/interfaces/ViewPresenter.java index edf37726..5823647e 100755 --- a/ZBLibrary/src/main/java/zuo/biao/library/interfaces/ViewPresenter.java +++ b/ZBLibrary/src/main/java/zuo/biao/library/interfaces/ViewPresenter.java @@ -44,17 +44,5 @@ public interface ViewPresenter { @Nullable public String getForwardName(); - /* - * 如果需要自定义tab layout 需要实现此方法 - * TopTabView 构造函数中,第二个参数为最小宽度,可以默认传入0即可 - * */ - - default TopTabView setTopBarLayout(Activity context, int minWidth , @LayoutRes int layoutId){ - if (layoutId == 0){ - return new TopTabView(context); - }else { - return new TopTabView(context,0,layoutId); - } - } } \ No newline at end of file diff --git a/ZBLibrary/src/main/java/zuo/biao/library/ui/TopTabView.java b/ZBLibrary/src/main/java/zuo/biao/library/ui/TopTabView.java index 677ed119..31f2433c 100755 --- a/ZBLibrary/src/main/java/zuo/biao/library/ui/TopTabView.java +++ b/ZBLibrary/src/main/java/zuo/biao/library/ui/TopTabView.java @@ -70,7 +70,7 @@ public TopTabView(Activity context, int minWidth) { } public TopTabView(Activity context, int minWidth, @LayoutRes int resource){ - super(context,resource); + super(context, resource); this.minWidth = minWidth; this.inflater = context.getLayoutInflater(); } @@ -189,7 +189,6 @@ public void onClick(View v) { private TextView[] tvTabs; /**选择tab * @param position - * @param tabType */ public void select(int position) { Log.i(TAG, "select position = " + position); diff --git a/app/src/main/java/zblibrary/demo/DEMO/DemoTabActivity.java b/app/src/main/java/zblibrary/demo/DEMO/DemoTabActivity.java index cc8a96de..cb46ea4c 100755 --- a/app/src/main/java/zblibrary/demo/DEMO/DemoTabActivity.java +++ b/app/src/main/java/zblibrary/demo/DEMO/DemoTabActivity.java @@ -85,15 +85,12 @@ public void onClick(View v) { //示例代码>>>>>>>> } - /* - * 当需要自定义 tab bar layout时,要实现此方法 - * - * */ - - @Override - public int setTabBarLayout() { - return zuo.biao.library.R.layout.top_tab_view; - } + /**当需要自定义 tab bar layout时,要实现此方法 + */ + // @Override + // public int getTopTabViewResId() { + // return R.layout.top_tab_view; + // } //UI显示区(操作UI,但不存在数据获取或处理代码,也不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> diff --git a/app/src/main/java/zblibrary/demo/DEMO/DemoTabFragment.java b/app/src/main/java/zblibrary/demo/DEMO/DemoTabFragment.java index c00d5ea2..29cca6d1 100755 --- a/app/src/main/java/zblibrary/demo/DEMO/DemoTabFragment.java +++ b/app/src/main/java/zblibrary/demo/DEMO/DemoTabFragment.java @@ -92,15 +92,13 @@ public void initView() {//必须在onCreate方法内调用 tvDemoTabLeft = findView(R.id.tvDemoTabLeft); } - /* - * 当需要自定义 tab bar layout时,要实现此方法 - * - * */ - @Override - public int setTabBarLayout() { - return zuo.biao.library.R.layout.top_tab_view; - } + /**当需要自定义 tab bar layout时,要实现此方法 + */ + // @Override + // public int getTopTabViewResId() { + // return R.layout.top_tab_view; + // } /**一行代码没必要新建方法,这里是为了给DemoBottomTabActivity调用 */