diff --git a/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseActivity.java b/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseActivity.java
index 78e8328..fd26a50 100644
--- a/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseActivity.java
+++ b/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseActivity.java
@@ -1,12 +1,16 @@
package com.qhclh.ytzh.index.shangpin;
+import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseActivity;
import butterknife.BindView;
+import butterknife.OnClick;
/**
* Created by 青花瓷 on 2017/12/28.
@@ -15,6 +19,35 @@ import butterknife.BindView;
public class InHouseActivity extends BaseActivity {
@BindView(R.id.toolbar)
Toolbar mToolbar;
+
+ @BindView(R.id.iv_inhouse_all)
+ ImageView iv_inhouse_all;
+ @BindView(R.id.tv_inhouse_all)
+ TextView tv_inhouse_all;
+
+ @BindView(R.id.iv_inhouse_no)
+ ImageView iv_inhouse_no;
+ @BindView(R.id.tv_inhouse_no)
+ TextView tv_inhouse_no;
+
+ @BindView(R.id.iv_inhouse_yes)
+ ImageView iv_inhouse_yes;
+ @BindView(R.id.tv_inhouse_yes)
+ TextView tv_inhouse_yes;
+
+ ///< all
+ private static final int TAB_POSITION_ALL = 0;
+ ///< no
+ private static final int TAB_POSITION_NO = 1;
+ ///< yes
+ private static final int TAB_POSITION_YES = 2;
+ private int mCurrentTabPosition = -1;
+ private int mTargetTabPosition = TAB_POSITION_ALL;
+
+ private InHouseAllFragment inHouseAllFragment;
+ private InHouseNoFragment inHouseNoFragment;
+ private InHouseYesFragment inHouseYesFragment;
+
@Override
protected int setLayoutId() {
return R.layout.act_inhouse;
@@ -28,6 +61,8 @@ public class InHouseActivity extends BaseActivity {
finish();
}
});
+ ///< 点击切换fragment
+ onTabClick(mTargetTabPosition);
}
@Override
@@ -39,4 +74,124 @@ public class InHouseActivity extends BaseActivity {
protected void initOper() {
}
+
+ @OnClick({R.id.ll_inhouse_all, R.id.ll_inhouse_no, R.id.ll_inhouse_yes})
+ public void onClick(View view) {
+ switch (view.getId()) {
+ ///< all
+ case R.id.ll_inhouse_all: {
+ onTabClick(TAB_POSITION_ALL);
+ break;
+ }
+ ///< no
+ case R.id.ll_inhouse_no: {
+ onTabClick(TAB_POSITION_NO);
+ break;
+ }
+
+ ///< yes
+ case R.id.ll_inhouse_yes: {
+ onTabClick(TAB_POSITION_YES);
+ break;
+ }
+ }
+ }
+
+ private void onTabClick(int tabPosition) {
+ if (mCurrentTabPosition == tabPosition) {
+ return;
+ }
+ mCurrentTabPosition = tabPosition;
+ changeTabState(tabPosition);
+ changeFragment(tabPosition);
+ }
+
+ private void changeTabState(int tabPosition) {
+ clearAllTabState();
+ switch (tabPosition) {
+ case TAB_POSITION_ALL: {
+ iv_inhouse_all.setImageResource(R.drawable.shouye_3x);
+ tv_inhouse_all.setTextColor(getResources().getColor(R.color.colorPrimary));
+ break;
+ }
+
+ case TAB_POSITION_NO: {
+ iv_inhouse_no.setImageResource(R.drawable.gongzuo_3x);
+ tv_inhouse_no.setTextColor(getResources().getColor(R.color.colorPrimary));
+ break;
+ }
+ case TAB_POSITION_YES: {
+ iv_inhouse_yes.setImageResource(R.drawable.wode_3x);
+ tv_inhouse_yes.setTextColor(getResources().getColor(R.color.colorPrimary));
+ break;
+ }
+
+ }
+ }
+
+ private void clearAllTabState() {
+ ///< all
+ iv_inhouse_all.setImageResource(R.drawable.shouye1_3x);
+ tv_inhouse_all.setTextColor(getResources().getColor(R.color.grey_767c82));
+ ///< no
+ iv_inhouse_no.setImageResource(R.drawable.gongzuo1_3x);
+ tv_inhouse_no.setTextColor(getResources().getColor(R.color.grey_767c82));
+
+ ///< yes
+ iv_inhouse_yes.setImageResource(R.drawable.wode1_3x);
+ tv_inhouse_yes.setTextColor(getResources().getColor(R.color.grey_767c82));
+
+ }
+
+
+ private void changeFragment(int tabPosition) {
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ hideFragment(transaction);
+ switch (tabPosition) {
+ case TAB_POSITION_ALL: {
+ if (inHouseAllFragment == null) {
+ inHouseAllFragment = new InHouseAllFragment();
+ transaction.add(R.id.inhouse_container, inHouseAllFragment);
+ } else {
+ transaction.show(inHouseAllFragment);
+ }
+ break;
+ }
+
+ case TAB_POSITION_NO: {
+ if (inHouseNoFragment == null) {
+ inHouseNoFragment = new InHouseNoFragment();
+ transaction.add(R.id.inhouse_container, inHouseNoFragment);
+ } else {
+ transaction.show(inHouseNoFragment);
+ }
+ break;
+ }
+
+ case TAB_POSITION_YES: {
+ if (inHouseYesFragment == null) {
+ inHouseYesFragment = new InHouseYesFragment();
+ transaction.add(R.id.inhouse_container, inHouseYesFragment);
+ } else {
+ transaction.show(inHouseYesFragment);
+ }
+ break;
+ }
+
+ }
+ transaction.commitAllowingStateLoss();
+ }
+
+ private void hideFragment(FragmentTransaction transaction) {
+ if (inHouseAllFragment != null) {
+ transaction.hide(inHouseAllFragment);
+ }
+
+ if (inHouseNoFragment != null) {
+ transaction.hide(inHouseNoFragment);
+ }
+ if (inHouseYesFragment != null) {
+ transaction.hide(inHouseYesFragment);
+ }
+ }
}
diff --git a/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseAllFragment.java b/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseAllFragment.java
new file mode 100644
index 0000000..a7dc771
--- /dev/null
+++ b/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseAllFragment.java
@@ -0,0 +1,30 @@
+package com.qhclh.ytzh.index.shangpin;
+
+import com.qhclh.ytzh.R;
+import com.qhclh.ytzh.base.BaseFragment;
+
+/**
+ * Created by 青花瓷 on 2017/12/28.
+ */
+
+public class InHouseAllFragment extends BaseFragment {
+ @Override
+ protected int setLayout() {
+ return R.layout.frag_inhouse_all;
+ }
+
+ @Override
+ protected void initView() {
+
+ }
+
+ @Override
+ protected void initData() {
+
+ }
+
+ @Override
+ protected void initOper() {
+
+ }
+}
diff --git a/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseNoFragment.java b/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseNoFragment.java
new file mode 100644
index 0000000..53e0e15
--- /dev/null
+++ b/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseNoFragment.java
@@ -0,0 +1,30 @@
+package com.qhclh.ytzh.index.shangpin;
+
+import com.qhclh.ytzh.R;
+import com.qhclh.ytzh.base.BaseFragment;
+
+/**
+ * Created by 青花瓷 on 2017/12/28.
+ */
+
+public class InHouseNoFragment extends BaseFragment {
+ @Override
+ protected int setLayout() {
+ return R.layout.frag_inhouse_no;
+ }
+
+ @Override
+ protected void initView() {
+
+ }
+
+ @Override
+ protected void initData() {
+
+ }
+
+ @Override
+ protected void initOper() {
+
+ }
+}
diff --git a/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseYesFragment.java b/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseYesFragment.java
new file mode 100644
index 0000000..b16c380
--- /dev/null
+++ b/app/src/main/java/com/qhclh/ytzh/index/shangpin/InHouseYesFragment.java
@@ -0,0 +1,30 @@
+package com.qhclh.ytzh.index.shangpin;
+
+import com.qhclh.ytzh.R;
+import com.qhclh.ytzh.base.BaseFragment;
+
+/**
+ * Created by 青花瓷 on 2017/12/28.
+ */
+
+public class InHouseYesFragment extends BaseFragment {
+ @Override
+ protected int setLayout() {
+ return R.layout.frag_inhouse_yes;
+ }
+
+ @Override
+ protected void initView() {
+
+ }
+
+ @Override
+ protected void initData() {
+
+ }
+
+ @Override
+ protected void initOper() {
+
+ }
+}
diff --git a/app/src/main/res/layout/act_inhouse.xml b/app/src/main/res/layout/act_inhouse.xml
index 1cc64ed..fbfe946 100644
--- a/app/src/main/res/layout/act_inhouse.xml
+++ b/app/src/main/res/layout/act_inhouse.xml
@@ -8,7 +8,7 @@
diff --git a/app/src/main/res/layout/frag_inhouse_all.xml b/app/src/main/res/layout/frag_inhouse_all.xml
new file mode 100644
index 0000000..2600433
--- /dev/null
+++ b/app/src/main/res/layout/frag_inhouse_all.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/frag_inhouse_no.xml b/app/src/main/res/layout/frag_inhouse_no.xml
new file mode 100644
index 0000000..f907d34
--- /dev/null
+++ b/app/src/main/res/layout/frag_inhouse_no.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/frag_inhouse_yes.xml b/app/src/main/res/layout/frag_inhouse_yes.xml
new file mode 100644
index 0000000..cd12d02
--- /dev/null
+++ b/app/src/main/res/layout/frag_inhouse_yes.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/include_inhousetab_bar.xml b/app/src/main/res/layout/include_inhousetab_bar.xml
index e35ad5c..29dbf16 100644
--- a/app/src/main/res/layout/include_inhousetab_bar.xml
+++ b/app/src/main/res/layout/include_inhousetab_bar.xml
@@ -11,7 +11,7 @@
+ style="@style/TabIconinhouse" />
+ style="@style/TabIconinhouse" />
+ style="@style/TabIconinhouse" />
@dimen/tab_icon_width
+
+