use of android.support.v4.view.PagerTabStrip in project Gadgetbridge by Freeyourgadget.
the class ChartsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_charts);
initDates();
IntentFilter filterLocal = new IntentFilter();
filterLocal.addAction(GBApplication.ACTION_QUIT);
filterLocal.addAction(GBDevice.ACTION_DEVICE_CHANGED);
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
Bundle extras = getIntent().getExtras();
if (extras != null) {
mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
} else {
throw new IllegalArgumentException("Must provide a device when invoking this activity");
}
swipeLayout = (SwipeRefreshLayout) findViewById(R.id.activity_swipe_layout);
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
fetchActivityData();
}
});
enableSwipeRefresh(true);
// Set up the ViewPager with the sections adapter.
viewPager = (ViewPager) findViewById(R.id.charts_pager);
viewPager.setAdapter(getPagerAdapter());
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
enableSwipeRefresh(state == ViewPager.SCROLL_STATE_IDLE);
}
});
dateBar = (ViewGroup) findViewById(R.id.charts_date_bar);
mDateControl = (TextView) findViewById(R.id.charts_text_date);
mDateControl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String detailedDuration = formatDetailedDuration();
new ShowDurationDialog(detailedDuration, ChartsActivity.this).show();
}
});
mPrevButton = (Button) findViewById(R.id.charts_previous);
mPrevButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handlePrevButtonClicked();
}
});
mNextButton = (Button) findViewById(R.id.charts_next);
mNextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleNextButtonClicked();
}
});
mPagerTabStrip = (PagerTabStrip) findViewById(R.id.charts_pagerTabStrip);
LinearLayout mainLayout = (LinearLayout) findViewById(R.id.charts_main_layout);
}
use of android.support.v4.view.PagerTabStrip in project Carbon by ZieIony.
the class TabsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tabs);
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new PagerAdapter() {
@Override
public CharSequence getPageTitle(int position) {
return "Page " + position;
}
public View getView(int position, ViewPager pager) {
return new RelativeLayout(pager.getContext(), null, R.attr.carbon_cardViewStyle);
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public int getCount() {
return 7;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ViewPager pager = (ViewPager) container;
View view = getView(position, pager);
pager.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object view) {
((ViewPager) container).removeView((View) view);
}
});
PagerTabStrip tabs = (PagerTabStrip) findViewById(R.id.pager_title_strip);
tabs.setViewPager(pager);
}
use of android.support.v4.view.PagerTabStrip in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppOpsSummary method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// initialize the inflater
mInflater = inflater;
View rootView = mInflater.inflate(R.layout.app_ops_summary, container, false);
mContentContainer = container;
mRootView = rootView;
CharSequence[] pageNames = getResources().getTextArray(R.array.app_ops_categories_cm);
AppOpsState.OpsTemplate[] templates = AppOpsState.ALL_TEMPLATES;
assert (pageNames.length == templates.length);
int specificTab = -1;
Bundle bundle = getArguments();
if (bundle != null) {
specificTab = Arrays.asList(pageNames).indexOf(bundle.getString("appops_tab", ""));
}
List<Pair<CharSequence, AppOpsState.OpsTemplate>> pageData = new ArrayList<>();
for (int i = 0; i < pageNames.length; i++) {
pageData.add(Pair.create(pageNames[i], templates[i]));
}
filterPageData(pageData, specificTab);
mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
mAdapter = new MyPagerAdapter(getChildFragmentManager(), pageData);
mViewPager.setAdapter(mAdapter);
mViewPager.setOnPageChangeListener(mAdapter);
PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);
// HACK - https://code.google.com/p/android/issues/detail?id=213359
((ViewPager.LayoutParams) tabs.getLayoutParams()).isDecor = true;
Resources.Theme theme = tabs.getContext().getTheme();
TypedValue typedValue = new TypedValue();
theme.resolveAttribute(android.R.attr.colorAccent, typedValue, true);
final int colorAccent = getContext().getColor(typedValue.resourceId);
tabs.setTabIndicatorColor(colorAccent);
// only when the view is added.
if (container instanceof PreferenceFrameLayout) {
((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
}
mActivity = getActivity();
return rootView;
}
Aggregations