Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 63 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ Declare __TabBarView__ and set a ViewPager

```java

LayoutInflater inflator =
(LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LayoutInflater inflator =
(LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View v = inflator.inflate(R.layout.custom_ab, null);
tabBarView = (TabBarView) v.findViewById(R.id.tab_bar);
View v = inflator.inflate(R.layout.custom_ab, null);
tabBarView = (TabBarView) v.findViewById(R.id.tab_bar);

getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().setCustomView(v);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().setCustomView(v);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);

tabBarView.setViewPager(mViewPager);
tabBarView.setViewPager(mViewPager);


```
Expand All @@ -39,51 +39,51 @@ Example using a simple pager adapter

```java

public class SectionsPagerAdapter extends FragmentPagerAdapter implements IconTabProvider{
public class SectionsPagerAdapter extends FragmentPagerAdapter implements IconTabProvider{

private int[] tab_icons={R.drawable.ic_tab1,
R.drawable.ic_tab2,
R.drawable.ic_tab3,
};
private int[] tab_icons={R.drawable.ic_tab1,
R.drawable.ic_tab2,
R.drawable.ic_tab3,
};


public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}

@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class
// below).
return PlaceholderFragment.newInstance(position + 1);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class
// below).
return PlaceholderFragment.newInstance(position + 1);
}

@Override
public int getCount() {
// Show 3 total pages.
return tab_icons.length;
}
@Override
public int getCount() {
// Show 3 total pages.
return tab_icons.length;
}

@Override
public int getPageIconResId(int position) {
return tab_icons[position];
}
@Override
public int getPageIconResId(int position) {
return tab_icons[position];
}

@Override
public CharSequence getPageTitle(int position) {
Locale l = Locale.getDefault();
switch (position) {
case 0:
return getString(R.string.title_section1).toUpperCase(l);
case 1:
return getString(R.string.title_section2).toUpperCase(l);
case 2:
return getString(R.string.title_section3).toUpperCase(l);
}
return null;
@Override
public CharSequence getPageTitle(int position) {
Locale l = Locale.getDefault();
switch (position) {
case 0:
return getString(R.string.title_section1).toUpperCase(l);
case 1:
return getString(R.string.title_section2).toUpperCase(l);
case 2:
return getString(R.string.title_section3).toUpperCase(l);
}
return null;
}
}

```
---
Expand All @@ -97,20 +97,21 @@ Example using a simple pager adapter

####License

```
Copyright 2014 Mirko Dimartino

Copyright 2014 Mirko Dimartino

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.
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.
```

####Developed by

Expand Down