From c015efb26c279b72ede9c755c005882d41779f21 Mon Sep 17 00:00:00 2001 From: fabiotovar Date: Thu, 26 Jul 2018 05:52:32 -0500 Subject: [PATCH 1/5] Library allows multiselection feature. --- app/build.gradle | 17 ++++--- .../kingja/switchbutton/ApplicationTest.java | 13 ------ .../com/kingja/switchbutton/MainActivity.java | 31 ++++++++----- app/src/main/res/layout/activity_main.xml | 1 - .../kingja/switchbutton/ApplicationTest.java | 45 +++++++++++++++++++ 5 files changed, 78 insertions(+), 29 deletions(-) delete mode 100644 app/src/androidTest/java/com/kingja/switchbutton/ApplicationTest.java create mode 100644 app/src/test/java/com/kingja/switchbutton/ApplicationTest.java diff --git a/app/build.gradle b/app/build.gradle index 35b2f51..7acf9c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,6 @@ apply plugin: 'com.android.application' android { compileSdkVersion 25 - buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { applicationId "com.lib.kingja.switchbutton" @@ -18,15 +17,23 @@ android { } } + testOptions{ + unitTests{ + includeAndroidResources = true + } + } + lintOptions { abortOnError false } + buildToolsVersion '27.0.3' } dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - testCompile 'junit:junit:4.12' - compile project(':libk-switchbutton') + implementation fileTree(include: ['*.jar'], dir: 'libs') + testImplementation 'junit:junit:4.12' + implementation project(':libk-switchbutton') // compile 'lib.kingja.switchbutton:switchbutton:1.1.6' - compile "com.android.support:appcompat-v7:$rootProject.ext.supportVersion" + implementation "com.android.support:appcompat-v7:$rootProject.ext.supportVersion" + testImplementation "org.robolectric:robolectric:3.8" } diff --git a/app/src/androidTest/java/com/kingja/switchbutton/ApplicationTest.java b/app/src/androidTest/java/com/kingja/switchbutton/ApplicationTest.java deleted file mode 100644 index c998a7e..0000000 --- a/app/src/androidTest/java/com/kingja/switchbutton/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.kingja.switchbutton; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/kingja/switchbutton/MainActivity.java b/app/src/main/java/com/kingja/switchbutton/MainActivity.java index 849b3a6..2485710 100644 --- a/app/src/main/java/com/kingja/switchbutton/MainActivity.java +++ b/app/src/main/java/com/kingja/switchbutton/MainActivity.java @@ -19,7 +19,6 @@ import android.os.Bundle; import android.support.v7.app.AppCompatActivity; -import android.widget.Toast; import com.lib.kingja.switchbutton.R; @@ -36,25 +35,37 @@ */ public class MainActivity extends AppCompatActivity { - private String[] tabTexts1 = {"才子", "帅哥", "大湿", "猛将兄"}; + private String[] tabTexts1 = {"test1", "test2", "test3", "test4"}; private String[] tabTexts4 = {"已经", "在家", "等你"}; + private SwitchMultiButton smb; + + private SwitchMultiButton.OnSwitchListener onSwitchListener = new SwitchMultiButton.OnSwitchListener() { + @Override + public void onSwitch(int position, String tabText) { + //Toast.makeText(MainActivity.this, tabText, Toast.LENGTH_SHORT).show(); + } + }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - ((SwitchMultiButton) findViewById(R.id.switchmultibutton1)).setText(tabTexts1).setOnSwitchListener(onSwitchListener); + smb = ((SwitchMultiButton) findViewById(R.id.switchmultibutton1)); + smb.setText(tabTexts1).setOnSwitchListener(onSwitchListener); + + Integer in[] = new Integer[]{0, 2}; + + for (Integer i : in) { + smb.setSelectedTab(i); + } + ((SwitchMultiButton) findViewById(R.id.switchmultibutton2)).setText("点个Star", "狠心拒绝").setOnSwitchListener(onSwitchListener); ((SwitchMultiButton) findViewById(switchmultibutton3)).setOnSwitchListener(onSwitchListener).setSelectedTab(1); ((SwitchMultiButton) findViewById(R.id.switchmultibutton4)).setText(tabTexts4).setOnSwitchListener(onSwitchListener); } - private SwitchMultiButton.OnSwitchListener onSwitchListener = new SwitchMultiButton.OnSwitchListener() { - @Override - public void onSwitch(int position, String tabText) { - Toast.makeText(MainActivity.this, tabText, Toast.LENGTH_SHORT).show(); - } - }; - + public SwitchMultiButton getSwitchMultiButton() { + return smb; + } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index cfcca24..7698935 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -16,7 +16,6 @@ android:paddingBottom="4dp" android:paddingTop="4dp" app:selectedColor="#1c7626" - app:selectedTab="1" app:strokeRadius="0dp" app:strokeWidth="1dp" app:textSize="14sp"/> diff --git a/app/src/test/java/com/kingja/switchbutton/ApplicationTest.java b/app/src/test/java/com/kingja/switchbutton/ApplicationTest.java new file mode 100644 index 0000000..b14b478 --- /dev/null +++ b/app/src/test/java/com/kingja/switchbutton/ApplicationTest.java @@ -0,0 +1,45 @@ +package com.kingja.switchbutton; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.Robolectric; +import org.robolectric.RobolectricTestRunner; + +import lib.kingja.switchbutton.SwitchMultiButton; + +import static org.junit.Assert.assertArrayEquals; + +/** + * Testing Fundamentals + */ +@RunWith(RobolectricTestRunner.class) +public class ApplicationTest { + @Test + public void testGetSelectedButtons() { + MainActivity a = Robolectric.setupActivity(MainActivity.class); + SwitchMultiButton smb = a.getSwitchMultiButton(); + Integer in[] = new Integer[]{0, 2}; + StringBuilder sb = new StringBuilder(); + sb.append("in: "); + + for (Integer i : in) { + smb.setSelectedTab(i); + sb.append(i).append(" "); + } + + sb.append("out: "); + + Integer out[] = smb.getSelectedTabs(); + + for (Integer i : out) { + sb.append(i).append(" "); + } + + assertArrayEquals(sb.toString(), in, out); + } + + @Test + public void testSelectAndUnselectButtons() { + + } +} \ No newline at end of file From 11ffaae99d45f43c5def13d637651fb556531225 Mon Sep 17 00:00:00 2001 From: fabiotovar Date: Thu, 26 Jul 2018 05:52:52 -0500 Subject: [PATCH 2/5] Library allows multiselection feature. --- libk-switchbutton/build.gradle | 19 ++++-- .../kingja/switchbutton/ApplicationTest.java | 30 --------- .../switchbutton/SwitchMultiButton.java | 67 +++++++++++-------- .../switchbutton/SwitchMultiButtonTest.java | 17 +++++ 4 files changed, 71 insertions(+), 62 deletions(-) delete mode 100644 libk-switchbutton/src/androidTest/java/lib/kingja/switchbutton/ApplicationTest.java create mode 100644 libk-switchbutton/src/test/java/lib/kingja/switchbutton/SwitchMultiButtonTest.java diff --git a/libk-switchbutton/build.gradle b/libk-switchbutton/build.gradle index 043dd79..dc203d8 100644 --- a/libk-switchbutton/build.gradle +++ b/libk-switchbutton/build.gradle @@ -1,7 +1,6 @@ apply plugin: 'com.android.library' android { compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -15,10 +14,22 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + buildToolsVersion '27.0.3' } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' - compile "com.android.support:appcompat-v7:$rootProject.ext.supportVersion" + implementation fileTree(dir: 'libs', include: ['*.jar']) + + implementation "com.android.support:appcompat-v7:25.3.1" + // Required for instrumented tests + testImplementation 'junit:junit:4.12' + testImplementation 'org.mockito:mockito-core:2.4.0' + testImplementation 'org.powermock:powermock-core:1.7.0RC2' + testImplementation 'org.powermock:powermock-module-junit4:1.7.0RC2' + testImplementation 'org.powermock:powermock-api-mockito2:1.7.0RC2' + testImplementation "org.robolectric:robolectric:3.8" + + androidTestImplementation 'com.android.support:support-annotations:27.1.1' + androidTestImplementation 'org.testng:testng:6.9.6' + androidTestImplementation 'com.android.support.test:runner:1.0.2' } diff --git a/libk-switchbutton/src/androidTest/java/lib/kingja/switchbutton/ApplicationTest.java b/libk-switchbutton/src/androidTest/java/lib/kingja/switchbutton/ApplicationTest.java deleted file mode 100644 index e0dfa0b..0000000 --- a/libk-switchbutton/src/androidTest/java/lib/kingja/switchbutton/ApplicationTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2016 KingJA - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package lib.kingja.switchbutton; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java b/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java index d939c37..2fd805a 100644 --- a/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java +++ b/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java @@ -33,6 +33,9 @@ import android.view.MotionEvent; import android.view.View; +import java.util.HashSet; +import java.util.Set; + /** * Description A smart switchable button,support multiple tabs. * Create Time 2016/7/27 14:57 @@ -42,15 +45,15 @@ public class SwitchMultiButton extends View { private static final String TAG = "SwitchMultiButton"; - /*default value*/ - private String[] mTabTexts = {"L", "R"}; - private int mTabNum = mTabTexts.length; private static final float STROKE_RADIUS = 0; private static final float STROKE_WIDTH = 2; private static final float TEXT_SIZE = 14; private static final int SELECTED_COLOR = 0xffeb7b00; private static final int SELECTED_TAB = 0; private static final String FONTS_DIR = "fonts/"; + /*default value*/ + private String[] mTabTexts = {"L", "R"}; + private int mTabNum = mTabTexts.length; /*other*/ private Paint mStrokePaint; private Paint mFillPaint; @@ -63,7 +66,7 @@ public class SwitchMultiButton extends View { private float mStrokeWidth; private int mSelectedColor; private float mTextSize; - private int mSelectedTab; + private Set mSelectedTabs; private String mTypeface; private float perWidth; private float mTextHeightOffset; @@ -92,18 +95,23 @@ public SwitchMultiButton(Context context, AttributeSet attrs, int defStyleAttr) * @param attrs */ private void initAttrs(Context context, AttributeSet attrs) { + mSelectedTabs = new HashSet<>(); + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwitchMultiButton); mStrokeRadius = typedArray.getDimension(R.styleable.SwitchMultiButton_strokeRadius, STROKE_RADIUS); mStrokeWidth = typedArray.getDimension(R.styleable.SwitchMultiButton_strokeWidth, STROKE_WIDTH); mTextSize = typedArray.getDimension(R.styleable.SwitchMultiButton_textSize, TEXT_SIZE); mSelectedColor = typedArray.getColor(R.styleable.SwitchMultiButton_selectedColor, SELECTED_COLOR); - mSelectedTab = typedArray.getInteger(R.styleable.SwitchMultiButton_selectedTab, SELECTED_TAB); + mSelectedTabs.add(typedArray.getInteger(R.styleable.SwitchMultiButton_selectedTab, SELECTED_TAB)); mTypeface = typedArray.getString(R.styleable.SwitchMultiButton_typeface); + int mSwitchTabsResId = typedArray.getResourceId(R.styleable.SwitchMultiButton_switchTabs, 0); + if (mSwitchTabsResId != 0) { - mTabTexts = getResources().getStringArray(mSwitchTabsResId); + mTabTexts = context.getResources().getStringArray(mSwitchTabsResId); mTabNum = mTabTexts.length; } + if (!TextUtils.isEmpty(mTypeface)) { typeface = Typeface.createFromAsset(context.getAssets(), FONTS_DIR + mTypeface); } @@ -220,7 +228,8 @@ protected void onDraw(Canvas canvas) { for (int i = 0; i < mTabNum; i++) { String tabText = mTabTexts[i]; float tabTextWidth = mSelectedTextPaint.measureText(tabText); - if (i == mSelectedTab) { + + if (mSelectedTabs.contains(i)) { //draw selected tab if (i == 0) { drawLeftPath(canvas, left, top, bottom); @@ -234,7 +243,6 @@ protected void onDraw(Canvas canvas) { // draw selected text canvas.drawText(tabText, 0.5f * perWidth * (2 * i + 1) - 0.5f * tabTextWidth, mHeight * 0.5f + mTextHeightOffset, mSelectedTextPaint); - } else { //draw unselected text canvas.drawText(tabText, 0.5f * perWidth * (2 * i + 1) - 0.5f * tabTextWidth, mHeight * 0.5f + @@ -322,10 +330,13 @@ public boolean onTouchEvent(MotionEvent event) { float x = event.getX(); for (int i = 0; i < mTabNum; i++) { if (x > perWidth * i && x < perWidth * (i + 1)) { - if (mSelectedTab == i) { - return true; + if (mSelectedTabs.contains(i)) { + mSelectedTabs.remove(i); + } else { + mSelectedTabs.add(i); } - mSelectedTab = i; + //mSelectedTabs.clear(); + if (onSwitchListener != null) { onSwitchListener.onSwitch(i, mTabTexts[i]); } @@ -338,27 +349,20 @@ public boolean onTouchEvent(MotionEvent event) { /*=========================================Interface=========================================*/ - /** - * called when swtiched - */ - public interface OnSwitchListener { - void onSwitch(int position, String tabText); - } - public SwitchMultiButton setOnSwitchListener(@NonNull OnSwitchListener onSwitchListener) { this.onSwitchListener = onSwitchListener; return this; } - /*=========================================Set and Get=========================================*/ - /** * get position of selected tab */ - public int getSelectedTab() { - return mSelectedTab; + public Integer[] getSelectedTabs() { + return mSelectedTabs.toArray(new Integer[mSelectedTabs.size()]); } + /*=========================================Set and Get=========================================*/ + /** * set selected tab * @@ -366,7 +370,7 @@ public int getSelectedTab() { * @return */ public SwitchMultiButton setSelectedTab(int mSelectedTab) { - this.mSelectedTab = mSelectedTab; + this.mSelectedTabs.add(mSelectedTab); invalidate(); if (onSwitchListener != null) { onSwitchListener.onSwitch(mSelectedTab, mTabTexts[mSelectedTab]); @@ -374,8 +378,8 @@ public SwitchMultiButton setSelectedTab(int mSelectedTab) { return this; } - public void clearSelection() { - this.mSelectedTab = -1; + public void clearSelectioned() { + this.mSelectedTabs.clear(); invalidate(); } @@ -395,7 +399,6 @@ public SwitchMultiButton setText(String... tagTexts) { throw new IllegalArgumentException("the size of tagTexts should greater then 1"); } } - /*======================================save and restore======================================*/ @Override protected Parcelable onSaveInstanceState() { @@ -405,9 +408,10 @@ protected Parcelable onSaveInstanceState() { bundle.putFloat("StrokeWidth", mStrokeWidth); bundle.putFloat("TextSize", mTextSize); bundle.putInt("SelectedColor", mSelectedColor); - bundle.putInt("SelectedTab", mSelectedTab); + bundle.putSerializable("SelectedTab", (HashSet) mSelectedTabs); return bundle; } + /*======================================save and restore======================================*/ @Override protected void onRestoreInstanceState(Parcelable state) { @@ -417,10 +421,17 @@ protected void onRestoreInstanceState(Parcelable state) { mStrokeWidth = bundle.getFloat("StrokeWidth"); mTextSize = bundle.getFloat("TextSize"); mSelectedColor = bundle.getInt("SelectedColor"); - mSelectedTab = bundle.getInt("SelectedTab"); + mSelectedTabs = (HashSet) bundle.getSerializable("SelectedTab"); super.onRestoreInstanceState(bundle.getParcelable("View")); } else { super.onRestoreInstanceState(state); } } + + /** + * called when swtiched + */ + public interface OnSwitchListener { + void onSwitch(int position, String tabText); + } } diff --git a/libk-switchbutton/src/test/java/lib/kingja/switchbutton/SwitchMultiButtonTest.java b/libk-switchbutton/src/test/java/lib/kingja/switchbutton/SwitchMultiButtonTest.java new file mode 100644 index 0000000..cf52efc --- /dev/null +++ b/libk-switchbutton/src/test/java/lib/kingja/switchbutton/SwitchMultiButtonTest.java @@ -0,0 +1,17 @@ +package lib.kingja.switchbutton; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.Robolectric; +import org.robolectric.RobolectricTestRunner; + +/** + * Testing Fundamentals + */ +@RunWith(RobolectricTestRunner.class) +public class SwitchMultiButtonTest { + @Test + public void getSelectedButtons() { + + } +} \ No newline at end of file From 93de4019e7fc040f65cf7a870bb45c35057f6d15 Mon Sep 17 00:00:00 2001 From: fabiotovar Date: Thu, 26 Jul 2018 08:06:56 -0500 Subject: [PATCH 3/5] Added util functions --- .idea/checkstyle-idea.xml | 15 - .idea/compiler.xml | 22 -- .idea/copyright/profiles_settings.xml | 3 - .idea/encodings.xml | 6 - .idea/misc.xml | 31 +- .idea/modules.xml | 2 +- .idea/qaplug_profiles.xml | 289 ------------------ .../com/kingja/switchbutton/MainActivity.java | 50 +++ app/src/main/res/layout/activity_main.xml | 50 ++- .../kingja/switchbutton/ApplicationTest.java | 59 +++- build.gradle | 4 +- gradle/wrapper/gradle-wrapper.properties | 4 +- .../switchbutton/SwitchMultiButton.java | 33 +- 13 files changed, 188 insertions(+), 380 deletions(-) delete mode 100644 .idea/checkstyle-idea.xml delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/qaplug_profiles.xml diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml deleted file mode 100644 index 183ec08..0000000 --- a/.idea/checkstyle-idea.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 96cc43e..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0a0c222..99202cc 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,18 +1,16 @@ - - - @@ -27,29 +25,10 @@ - + - - - - - - - 1.8 - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index f702f35..dfb3ec7 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml deleted file mode 100644 index e24d63d..0000000 --- a/.idea/qaplug_profiles.xml +++ /dev/null @@ -1,289 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/kingja/switchbutton/MainActivity.java b/app/src/main/java/com/kingja/switchbutton/MainActivity.java index 2485710..0a9dfac 100644 --- a/app/src/main/java/com/kingja/switchbutton/MainActivity.java +++ b/app/src/main/java/com/kingja/switchbutton/MainActivity.java @@ -19,6 +19,11 @@ import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.Switch; +import android.widget.Toast; import com.lib.kingja.switchbutton.R; @@ -38,6 +43,7 @@ public class MainActivity extends AppCompatActivity { private String[] tabTexts1 = {"test1", "test2", "test3", "test4"}; private String[] tabTexts4 = {"已经", "在家", "等你"}; private SwitchMultiButton smb; + private boolean showToast = false; private SwitchMultiButton.OnSwitchListener onSwitchListener = new SwitchMultiButton.OnSwitchListener() { @Override @@ -63,6 +69,50 @@ protected void onCreate(Bundle savedInstanceState) { ((SwitchMultiButton) findViewById(R.id.switchmultibutton2)).setText("点个Star", "狠心拒绝").setOnSwitchListener(onSwitchListener); ((SwitchMultiButton) findViewById(switchmultibutton3)).setOnSwitchListener(onSwitchListener).setSelectedTab(1); ((SwitchMultiButton) findViewById(R.id.switchmultibutton4)).setText(tabTexts4).setOnSwitchListener(onSwitchListener); + + Button unselect = (Button) findViewById(R.id.button); + Button select = (Button) findViewById(R.id.button2); + Switch sw = (Switch) findViewById(R.id.switch1); + + unselect.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + smb.clearSelected(); + } + }); + + select.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Runnable r = new Runnable() { + @Override + public void run() { + for (int i = 0; i < tabTexts1.length; i++) { + final int ii[] = new int[1]; + ii[0] = i; + smb.setSelectedTab(ii[0]); + } + } + }; + + new Thread(r).run(); + } + }); + + sw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + showToast = isChecked; + } + }); + + smb.setOnSwitchListener(new SwitchMultiButton.OnSwitchListener() { + @Override + public void onSwitch(int position, String tabText) { + if (showToast) + Toast.makeText(getBaseContext(), tabText + " pressed", Toast.LENGTH_SHORT).show(); + } + }); } public SwitchMultiButton getSwitchMultiButton() { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 7698935..0ccd4e8 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,11 +1,11 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center_horizontal" + android:orientation="vertical" + android:padding="16dp"> + app:textSize="14sp" /> + app:textSize="14sp" /> + app:textSize="14sp" + app:typeface="tielanti.ttf" /> + app:textSize="14sp" /> + app:typeface="DeVinneTxtBT.ttf" /> + + + +