MultiTabMenu
MultiTabMenu support for Android 2.1(Eclair)+
Gradle
repositories{
maven { url 'https://jitpack.io' }
}
dependencies{
compile 'com.github.iamvaliyev:MultiTabMenu:v1.0.1'
}
How to use?
You can also inflate MultiTabMenu from XML:
<io.github.iamvaliyev.multitabmenu.MultiTabMenu
android:id="@+id/multiTabMenu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
Java Code
multiTabMenu = (MultiTabMenu) findViewById(R.id.multiTabMenu);
multiTabMenu.getSelectedCategory(); // return Category
multiTabMenu.getSelectedSubCategory(); // return Object
multiTabMenu.getSelectedCategoryPosition(); // return int
multiTabMenu.getSelectedSubCategoryPosition(); // return int
Setup Adapter:
multiTabMenu.setupSubCategories(new CategoryAdapter(getApplicationContext(), list));
Listener:
multiTabMenu.setOnCategorySelectedListener(new MultiTabMenu.OnCategorySelectedListener() {
@Override
public void onCategorySelected(Category category) {
....
}
@Override
public void OnSubCategorySelected(Object object) {
....
}
});
Adapter:
public class CategoryAdapter extends ParentAdapter {
List<Cat> list;
public CategoryAdapter(Context context, List<Cat> list) {
super(context, list);
.......
}
@Override
public View getSectionView(int position, View view, ViewGroup parent) {
.......
}
@Override
public View getChildView(int position, int childPosition, View view, ViewGroup parent) {
.......
}
}
Model with CategoryWrapper:
public class YourCategoryModel implements Category<YourSubCategoryModel> {
String title;
List<YourSubCategoryModel> list = new ArrayList<>();
public Cat(String title) {
this.title = title;
}
@Override
public List getChildItems() {
return list;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<YourSubCategoryModel> getList() {
return list;
}
public void setList(List<YourSubCategoryModel> list) {
this.list = list;
}
public void add(SubCat subCat){
list.add(subCat);
}
}
Attributes
app:categoriesBackground="@color/colorPrimaryDark"
app:subCategoriesBackground="@color/colorPrimary"
app:triangleBackground="@color/colorAccent"