This repository has been archived by the owner on Apr 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
joined two project, updated to version 0.11
- Loading branch information
Fabio Biola
authored and
Fabio Biola
committed
Dec 30, 2014
1 parent
1f45f9c
commit 361e8f2
Showing
75 changed files
with
402 additions
and
818 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="it.neokree.materialtabtest" > | ||
package="it.neokree.materialtabtest"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name="it.neokree.materialtabtest.MainActivity" | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".IconTabActivity" /> | ||
<activity android:name=".SwipableIconTabActivity" /> | ||
<activity android:name=".SwipableTextTabActivity" /> | ||
<activity android:name=".TextTabActivity" /> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
MaterialTabTest/app/src/main/java/it/neokree/materialtabtest/SwipableIconTabActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package it.neokree.materialtabtest; | ||
|
||
/** | ||
* Created by neokree on 30/12/14. | ||
*/ | ||
|
||
import android.content.res.Resources; | ||
import android.graphics.Color; | ||
import android.graphics.drawable.Drawable; | ||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentManager; | ||
import android.support.v4.app.FragmentStatePagerAdapter; | ||
import android.support.v4.view.ViewPager; | ||
import android.support.v7.app.ActionBarActivity; | ||
import android.support.v7.widget.Toolbar; | ||
|
||
import it.neokree.materialtabs.MaterialTab; | ||
import it.neokree.materialtabs.MaterialTabHost; | ||
import it.neokree.materialtabs.MaterialTabListener; | ||
|
||
/** | ||
* Created by neokree on 30/12/14. | ||
*/ | ||
public class SwipableIconTabActivity extends ActionBarActivity implements MaterialTabListener { | ||
private ViewPager pager; | ||
private ViewPagerAdapter pagerAdapter; | ||
MaterialTabHost tabHost; | ||
private Resources res; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_icons); | ||
res = this.getResources(); | ||
// init toolbar (old action bar) | ||
|
||
Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar); | ||
toolbar.setTitleTextColor(Color.WHITE); | ||
this.setSupportActionBar(toolbar); | ||
|
||
tabHost = (MaterialTabHost) this.findViewById(R.id.tabHost); | ||
pager = (ViewPager) this.findViewById(R.id.pager); | ||
// init view pager | ||
pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager()); | ||
pager.setAdapter(pagerAdapter); | ||
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { | ||
@Override | ||
public void onPageSelected(int position) { | ||
// when user do a swipe the selected tab change | ||
tabHost.setSelectedNavigationItem(position); | ||
} | ||
}); | ||
// insert all tabs from pagerAdapter data | ||
for (int i = 0; i < pagerAdapter.getCount(); i++) { | ||
tabHost.addTab( | ||
tabHost.newTab() | ||
.setIcon(getIcon(i)) | ||
.setTabListener(this) | ||
); | ||
} | ||
} | ||
@Override | ||
public void onTabSelected(MaterialTab tab) { | ||
// when the tab is clicked the pager swipe content to the tab position | ||
pager.setCurrentItem(tab.getPosition()); | ||
} | ||
|
||
@Override | ||
public void onTabReselected(MaterialTab tab) { | ||
} | ||
|
||
@Override | ||
public void onTabUnselected(MaterialTab tab) { | ||
} | ||
|
||
private class ViewPagerAdapter extends FragmentStatePagerAdapter { | ||
public ViewPagerAdapter(FragmentManager fm) { | ||
super(fm); | ||
} | ||
public Fragment getItem(int num) { | ||
return new FragmentText(); | ||
} | ||
@Override | ||
public int getCount() { | ||
return 6; | ||
} | ||
@Override | ||
public CharSequence getPageTitle(int position) { | ||
return "tab"; | ||
} | ||
} | ||
/* | ||
* It doesn't matter the color of the icons, but they must have solid colors | ||
*/ | ||
private Drawable getIcon(int position) { | ||
return res.getDrawable(R.drawable.ic_person_black_24dp); | ||
} | ||
|
||
} |
Oops, something went wrong.