Back to project page trivial-password.
The source code is released under:
MIT License
If you think the Android project trivial-password listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.hbabcock.trivialpassword; /* w w w .j av a 2s. c o m*/ import java.util.ArrayList; import java.util.UUID; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.ViewPager; public class AccountPagerActivity extends FragmentActivity { private ArrayList<Account> mAccounts; private ViewPager mViewPager; private Boolean mNewAccount; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_account_pager); mAccounts = AccountManager.get(this).getAccounts(); FragmentManager fm = getSupportFragmentManager(); mViewPager = (ViewPager)findViewById(R.id.pager); mViewPager.setAdapter(new FragmentStatePagerAdapter(fm){ @Override public int getCount(){ return mAccounts.size(); } @Override public Fragment getItem(int pos){ Account a = mAccounts.get(pos); Fragment f = AccountFragment.newInstance(a.getId(), mNewAccount); mNewAccount = false; return f; } }); mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){ public void onPageScrollStateChanged(int state){} public void onPageScrolled(int pos, float posOffset, int posOffsetPixels){} public void onPageSelected(int pos){ Account a = mAccounts.get(pos); if (a.getAccount() != null){ setTitle(a.getAccount()); } } }); UUID aId = (UUID)getIntent().getSerializableExtra(AccountFragment.EXTRA_ACCOUNT_ID); mNewAccount = (Boolean)getIntent().getSerializableExtra(AccountFragment.EXTRA_NEW_ACCOUNT); for (int i=0;i<mAccounts.size();i++){ if (mAccounts.get(i).getId().equals(aId)){ mViewPager.setCurrentItem(i); break; } } } }