use of android.support.v4.app.FragmentPagerAdapter in project Android-Boilerplate by hitherejoe.
the class DetailActivity method setupViewPager.
private void setupViewPager() {
mBeaconDetailViewPager.setOffscreenPageLimit(2);
mBeaconDetailViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
String[] titles = getResources().getStringArray(R.array.detail_fragment_titles);
@Override
public Fragment getItem(int position) {
switch(position) {
case 0:
return DetailFragment.newInstance((ArrayList<String>) mCharacter.films);
case 1:
return DetailFragment.newInstance((ArrayList<String>) mCharacter.vehicles);
case 2:
return DetailFragment.newInstance((ArrayList<String>) mCharacter.species);
case 3:
return DetailFragment.newInstance((ArrayList<String>) mCharacter.starships);
default:
return DetailFragment.newInstance(new ArrayList<String>());
}
}
@Override
public CharSequence getPageTitle(int position) {
return titles[position];
}
@Override
public int getCount() {
return titles.length;
}
});
mTabLayout.setupWithViewPager(mBeaconDetailViewPager);
}
use of android.support.v4.app.FragmentPagerAdapter in project FolderLayout by kyze8439690.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mFolderLayout = (FolderLayout) findViewById(R.id.folder_layout);
text1 = (TextView) findViewById(R.id.item1);
text2 = (TextView) findViewById(R.id.item2);
text3 = (TextView) findViewById(R.id.item3);
text4 = (TextView) findViewById(R.id.item4);
text1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mFolderLayout.toggleItem(3);
}
});
text2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mFolderLayout.toggleItem(2);
}
});
text3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mFolderLayout.toggleItem(1);
}
});
text4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mFolderLayout.toggleItem(0);
}
});
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
return new ListFragment();
}
@Override
public int getCount() {
return 3;
}
});
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new String[] { "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item" });
mListView = (ListView) findViewById(R.id.list);
mListView.setAdapter(adapter);
mGridView = (GridView) findViewById(R.id.grid);
mGridView.setAdapter(adapter);
}
use of android.support.v4.app.FragmentPagerAdapter in project FishChatAndroid by oikomi.
the class ChatMainActivity method initView.
private void initView() {
mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
mChatTextView = (TextView) findViewById(R.id.id_tv_chat);
mFriendTextView = (TextView) findViewById(R.id.id_tv_friend);
mContactTextView = (TextView) findViewById(R.id.id_tv_contact);
mMeTextView = (TextView) findViewById(R.id.id_tv_me);
mChatLinearLayout = (LinearLayout) findViewById(R.id.id_ll_chat);
mDatas = new ArrayList<Fragment>();
mDatas.add(tab01);
mDatas.add(tab02);
mDatas.add(tab03);
mDatas.add(tab04);
mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public int getCount() {
return mDatas.size();
}
@Override
public Fragment getItem(int arg0) {
return mDatas.get(arg0);
}
};
mViewPager.setAdapter(mAdapter);
mViewPager.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
resetTextView();
switch(position) {
case 0:
if (mBadgeView != null) {
mChatLinearLayout.removeView(mBadgeView);
}
mBadgeView = new BadgeView(ChatMainActivity.this);
mBadgeView.setBadgeCount(7);
mChatLinearLayout.addView(mBadgeView);
mChatTextView.setTextColor(Color.parseColor("#008000"));
break;
case 1:
mContactTextView.setTextColor(Color.parseColor("#008000"));
break;
case 2:
mFriendTextView.setTextColor(Color.parseColor("#008000"));
break;
case 3:
mMeTextView.setTextColor(Color.parseColor("#008000"));
break;
}
mCurrentPageIndex = position;
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPx) {
Log.e("TAG", position + " , " + positionOffset + " , " + positionOffsetPx);
LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) mTabline.getLayoutParams();
if (// 0->1
mCurrentPageIndex == 0 && position == 0) {
lp.leftMargin = (int) (positionOffset * mScreen1_4 + mCurrentPageIndex * mScreen1_4);
} else if (// 1->0
mCurrentPageIndex == 1 && position == 0) {
lp.leftMargin = (int) (mCurrentPageIndex * mScreen1_4 + (positionOffset - 1) * mScreen1_4);
} else if (// 1->2
mCurrentPageIndex == 1 && position == 1) {
lp.leftMargin = (int) (mCurrentPageIndex * mScreen1_4 + positionOffset * mScreen1_4);
} else if (// 2->1
mCurrentPageIndex == 2 && position == 1) {
lp.leftMargin = (int) (mCurrentPageIndex * mScreen1_4 + (positionOffset - 1) * mScreen1_4);
} else if (// 2->3
mCurrentPageIndex == 2 && position == 2) {
lp.leftMargin = (int) (mCurrentPageIndex * mScreen1_4 + (positionOffset) * mScreen1_4);
} else if (// 3->2
mCurrentPageIndex == 3 && position == 1) {
lp.leftMargin = (int) (mCurrentPageIndex * mScreen1_4 + (positionOffset - 1) * mScreen1_4);
}
mTabline.setLayoutParams(lp);
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}
use of android.support.v4.app.FragmentPagerAdapter in project StickerCamera by Skykai521.
the class AlbumActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_album);
ButterKnife.inject(this);
albums = ImageUtils.findGalleries(this, paths, 0);
//ViewPagerçš„adapter
FragmentPagerAdapter adapter = new TabPageIndicatorAdapter(getSupportFragmentManager());
pager.setAdapter(adapter);
tab.setViewPager(pager);
}
use of android.support.v4.app.FragmentPagerAdapter in project PocketHub by pockethub.
the class FragmentPagerAdapter method clearAdapter.
/**
* This methods clears any fragments that may not apply to the newly
* selected org.
*
* @return this adapter
*/
public FragmentPagerAdapter clearAdapter() {
if (tags.isEmpty()) {
return this;
}
FragmentTransaction transaction = fragmentManager.beginTransaction();
for (String tag : tags) {
Fragment fragment = fragmentManager.findFragmentByTag(tag);
if (fragment != null) {
transaction.remove(fragment);
}
}
transaction.commit();
tags.clear();
return this;
}
Aggregations