I need tabs for the application I am developing. So I ended up with tablayout and it contains few tabs. Code is as follows:
private void setupNavTab() {
int[][] states = new int[][]{
new int[]{android.R.attr.state_selected},
new int[]{-android.R.attr.state_selected},
new int[]{-android.R.attr.state_enabled}
};
int[] colors = new int[]{
ContextCompat.getColor(getActivity(), R.color.cricut_selected_green),
ContextCompat.getColor(getActivity(), R.color.nav_bar_unselected_content),
ContextCompat.getColor(getActivity(), R.color.edit_button_text_color_inactive)
};
ColorStateList cslist = new ColorStateList(states, colors);
if (tabs != null) {
tabs.removeAllTabs();
tabs.setTabTextColors(cslist);
firstTab = tabs.newTab().setTag(TAB_FIRST);
View customFirstTabView = LayoutInflater.from(getActivity()).inflate(R.layout.tab_item_layout, null, false);
firstTabView = (TextView) customFirstTabView.findViewById(R.id.textContainer);
firstTabView.setText(R.string.first);
firstTabView.setTextColor(cslist);
firstTab.setCustomView(customFirstTabView);
secondTab = tabs.newTab().setTag(TAB_SECOND);
View customSecondView = LayoutInflater.from(getActivity()).inflate(R.layout.tab_item_layout, null, false);
secondTabView = (TextView) customSecondView.findViewById(R.id.textContainer);
secondTabView.setText(R.string.second);
secondTabView.setTextColor(cslist);
secondTab.setCustomView(customSecondView);
thirdTab = tabs.newTab().setTag(TAB_THIRD);
View customThirdTabView
= LayoutInflater.from(getActivity()).inflate(R.layout.tab_item_layout, null, false);
thirdTabView = (TextView) customThirdTabView.findViewById(R.id.textContainer);
thirdTabView.setText(R.string.third);
thirdTabView.setTextColor(cslist);
thirdTab.setCustomView(customThirdTabView);
tabs.addTab(firstTab, true);
tabs.addTab(secondTab, false);
tabs.addTab(thirdTab, false);
}
}
I am not using viewpager. Here the third tab should be inaccessible until the user completes necessary steps in firstTab and secondTab. Is there a way to disable the thirdTab before those steps are completed by the user?