Skip to content

Commit

Permalink
Added a sample for the icons only mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
roughike committed Mar 27, 2017
1 parent 0e209b6 commit 0e0c581
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</intent-filter>
</activity>
<activity android:name=".ThreeTabsActivity" />
<activity android:name=".IconsOnlyActivity" />
<activity android:name=".FiveColorChangingTabsActivity" android:theme="@style/AppTheme.TransNav" />
<activity android:name=".ThreeTabsQRActivity" android:theme="@style/AppTheme.TransNav" />
<activity android:name=".BadgeActivity" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.example.bottombar.sample;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.widget.TextView;
import android.widget.Toast;

import com.roughike.bottombar.BottomBar;
import com.roughike.bottombar.OnTabReselectListener;
import com.roughike.bottombar.OnTabSelectListener;

public class IconsOnlyActivity extends Activity {
private TextView messageView;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_icons_only);

messageView = (TextView) findViewById(R.id.messageView);

BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(@IdRes int tabId) {
messageView.setText(TabMessage.get(tabId, false));
}
});

bottomBar.setOnTabReselectListener(new OnTabReselectListener() {
@Override
public void onTabReSelected(@IdRes int tabId) {
Toast.makeText(getApplicationContext(), TabMessage.get(tabId, true), Toast.LENGTH_LONG).show();
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

findViewById(R.id.simple_three_tabs).setOnClickListener(this);
findViewById(R.id.icons_only).setOnClickListener(this);
findViewById(R.id.five_tabs_changing_colors).setOnClickListener(this);
findViewById(R.id.three_tabs_quick_return).setOnClickListener(this);
findViewById(R.id.five_tabs_custom_colors).setOnClickListener(this);
Expand All @@ -27,6 +28,9 @@ public void onClick(View v) {
case R.id.simple_three_tabs:
clazz = ThreeTabsActivity.class;
break;
case R.id.icons_only:
clazz = IconsOnlyActivity.class;
break;
case R.id.five_tabs_changing_colors:
clazz = FiveColorChangingTabsActivity.class;
break;
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/res/layout/activity_icons_only.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
android:id="@+id/messageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottomBar"
android:gravity="center"
android:text="Hi mom!" />

<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:bb_tabXmlResource="@xml/bottombar_tabs_five"
app:bb_behavior="iconsOnly" />

</RelativeLayout>
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
android:layout_height="wrap_content"
android:text="Simple example with three tabs" />

<Button
android:id="@+id/icons_only"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tabs with icons only" />

<Button
android:id="@+id/five_tabs_custom_colors"
android:layout_width="wrap_content"
Expand Down

0 comments on commit 0e0c581

Please sign in to comment.