protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* ScheduleManager.getInstance(this.getApplicationContext()); // check if this is first app use ActivityManager am = (ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE); int sizeStack = am.getRunningTasks(1).get(0).numActivities; if (sizeStack == 2) { // if first app use have user fill out profile Intent launchIntent = new Intent(this, ProfileActivity.class); this.startActivity(launchIntent); } else { // then set RUNBEFORE to true to turn profiles over to notification manager SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(MainActivity.RUNBEFORE, true); editor.commit(); } */ }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_paged_content); this.getSupportActionBar().setSubtitle(R.string.app_name); final PagedIntroActivity me = this; final ViewPager pager = (ViewPager) this.findViewById(R.id.pager_content); final ImageView background = (ImageView) this.findViewById(R.id.background_image); pager.setAdapter( new PagerAdapter() { public int getCount() { return 27; } public boolean isViewFromObject(View view, Object content) { return view.getTag().equals(content); } public void destroyItem(ViewGroup container, int position, Object content) { int toRemove = -1; for (int i = 0; i < container.getChildCount(); i++) { View child = container.getChildAt(i); if (this.isViewFromObject(child, content)) toRemove = i; } if (toRemove >= 0) container.removeViewAt(toRemove); } public Object instantiateItem(ViewGroup container, int position) { LayoutInflater inflater = (LayoutInflater) me.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.view_paged_content, null); String[] contentValues = me.getResources().getStringArray(R.array.intro_content); TextView content = (TextView) view.findViewById(R.id.content_text); content.setText(contentValues[position]); view.setTag("" + position); container.addView(view); LayoutParams layout = (LayoutParams) view.getLayoutParams(); layout.height = LayoutParams.MATCH_PARENT; layout.width = LayoutParams.MATCH_PARENT; view.setLayoutParams(layout); return view.getTag(); } }); pager.setOnPageChangeListener( new OnPageChangeListener() { public void onPageScrollStateChanged(int arg0) {} public void onPageScrolled(int arg0, float arg1, int arg2) {} public void onPageSelected(int position) { MenuItem back = me._menu.findItem(R.id.action_previous); MenuItem next = me._menu.findItem(R.id.action_next); MenuItem done = me._menu.findItem(R.id.action_done); int[] introImages = { R.drawable.greet_1, R.drawable.greet_2, R.drawable.greet_3, R.drawable.intent_1, R.drawable.intent_2, R.drawable.intent_3, R.drawable.intent_4, R.drawable.intent_5, R.drawable.intent_6, R.drawable.rumination_1, R.drawable.rumination_2, R.drawable.rumination_3, R.drawable.rumination_4, R.drawable.rumination_5, R.drawable.rumination_6, R.drawable.specific_4, R.drawable.specific_1, R.drawable.specific_2, R.drawable.specific_2, R.drawable.specific_4, R.drawable.specific_5, R.drawable.specific_7, R.drawable.specific_9, R.drawable.specific_11, R.drawable.conclusion_1, R.drawable.conclusion_2, R.drawable.conclusion_3 }; background.setImageResource(introImages[position]); back.setVisible(true); next.setVisible(true); done.setVisible(false); if (position == 0) back.setVisible(false); if (position == pager.getAdapter().getCount() - 1) { next.setVisible(false); done.setVisible(true); } // TODO: Pull out into strings file... me.getSupportActionBar() .setTitle("Page " + (position + 1) + " of " + pager.getAdapter().getCount()); } }); // TODO: Pull out into strings file... me.getSupportActionBar().setTitle("Page " + 1 + " of " + pager.getAdapter().getCount()); }