protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    if (twitter == null) {
      twitter = new TwitterFactory().getInstance();
    }
    if (accessToken == null) {
      loginToTwitter();
    }

    actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    Tab tab1 = actionBar.newTab();
    tab1.setText("ListView");
    tab1.setTabListener(new MyTabListener(first));

    Tab tab2 = actionBar.newTab();
    tab2.setText("Images");
    tab2.setTabListener(new MyTabListener(second));

    Tab tab3 = actionBar.newTab();
    tab3.setText("Tweets");
    tab3.setTabListener(new MyTabListener(third));

    actionBar.addTab(tab1);
    actionBar.addTab(tab2);
    actionBar.addTab(tab3);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // mCallbacks = (TaskCallbacks) this;
    DataSource dt = new DataSource(this);
    dt.init(this);

    ActionBar actionBar = (ActionBar) this.getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    boolean paginaRotate = false;
    this.tblListado =
        new TabsListener<ListadoFragment>(this, "Entidades", ListadoFragment.class, paginaRotate);
    boolean st1 = true, st2 = false, st3 = false;
    this.tblInicio =
        new TabsListener<InicioFragment>(this, "Inicio", InicioFragment.class, paginaRotate);

    actionBar.addTab(
        actionBar.newTab().setText(R.string.menu_inicio).setTabListener(tblInicio), 0, true);

    actionBar.addTab(
        actionBar.newTab().setText(R.string.menu_entidades).setTabListener(tblListado), 1, false);

    actionBar.addTab(
        actionBar
            .newTab()
            .setText(R.string.menu_emergencia)
            .setTabListener(
                new TabsListener<EmergencyFragment>(
                    this, "Emergencia", EmergencyFragment.class, paginaRotate)),
        2,
        false);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // isPaused = false;
    reverbEnabler = false; // true;
    g.setPlayerStateRepeat(0);

    BA = BluetoothAdapter.getDefaultAdapter();

    if (BA.isEnabled()) {
      String address = BA.getAddress();
      String name = BA.getName();
      toastText = name + " : " + address;
    } else {
      toastText = "Bluetooth is not enabled";
    }
    Toast.makeText(this, toastText, Toast.LENGTH_LONG).show();

    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setLogo(R.drawable.logo);
    getSupportActionBar().setDisplayUseLogoEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    simpleListFragment = new FragmentTab1();
    androidlidt = new FragmentTab2();
    androidversionlist = new FragmentTab3();
    azimuthControl = new FragmentTab4();
    audioFxFrag = new FragmentTab5();

    actionBar = getSupportActionBar();
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#505050")));
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    actionBar.addTab(actionBar.newTab().setText("One").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Two").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Three").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Four").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Five").setTabListener(this));

    SongsManager plm = new SongsManager();
    PlayListActivity.songsList = plm.getPlayList();

    mReverb = new PresetReverb(1, 0);
    mReverb.setPreset(PresetReverb.PRESET_SMALLROOM);
    mReverb.setEnabled(reverbEnabler);

    mEqualizer = new Equalizer(0, 0);
    mEqualizer.setEnabled(true);
  }
Beispiel #4
0
  private void setActionBar(ActionBar actionBar) {

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ActionBar.Tab tab1 = actionBar.newTab();
    tab1.setText("Home");
    tab1.setTabListener(this);

    actionBar.addTab(tab1);

    ActionBar.Tab tab2 = actionBar.newTab();
    tab2.setText("Favorite");
    tab2.setTabListener(this);
    actionBar.addTab(tab2);
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_member);
    // Initilization
    viewPager = (ViewPager) findViewById(R.id.pager);
    actionBar = getSupportActionBar();
    tabPagerAdapter = new TabPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(tabPagerAdapter);
    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Adding Tabs
    for (String tab_name : tabs) {
      actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this));
    }
    viewPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int i, float v, int i1) {}

          @Override
          public void onPageSelected(int i) {
            actionBar.setSelectedNavigationItem(i);
          }

          @Override
          public void onPageScrollStateChanged(int i) {}
        });
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   mViewPager = (ViewPager) findViewById(R.id.pager);
   mViewPager.setAdapter(new MyPageAdapter(getSupportFragmentManager()));
   mViewPager.setOnPageChangeListener(mPageChangeListener);
   final ActionBar actionBar = getSupportActionBar();
   if (actionBar != null) {
     actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
     actionBar.addTab(
         actionBar.newTab().setText(getString(R.string.tab_1_name)).setTabListener(mTabListener));
     actionBar.addTab(
         actionBar.newTab().setText(getString(R.string.tab_2_name)).setTabListener(mTabListener));
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    List<Fragment> tabs = new ArrayList<Fragment>();
    tabs.add(UsersFragment.getInstance());
    tabs.add(RoomsFragment.getInstance());

    sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), tabs);

    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(sectionsPagerAdapter);

    viewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    for (int i = 0; i < sectionsPagerAdapter.getCount(); i++) {
      actionBar.addTab(
          actionBar.newTab().setText(sectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
  }
Beispiel #8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    doBindService();

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {

      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home_screen_tab);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

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

    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
            mSectionsPagerAdapter.notifyDataSetChanged();
          }
        });

    // Add all of the tabs and a listener to each tab
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
  }
 public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
   TabInfo info = new TabInfo(clss, args);
   tab.setTag(info);
   tab.setTabListener(this);
   mTabs.add(info);
   mActionBar.addTab(tab);
   notifyDataSetChanged();
 }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {

    super.onActivityCreated(savedInstanceState);

    ActionBar actionbar = ((MainActivity) getActivity()).getSupportActionBar();

    actionbar.addTab(
        actionbar.newTab().setText(getString(R.string.title_fragment_list)).setTabListener(this));
    actionbar.addTab(
        actionbar.newTab().setText(getString(R.string.title_fragment_flags)).setTabListener(this));
    FragmentManager manager = getActivity().getSupportFragmentManager();
    manager
        .beginTransaction()
        .add(R.id.mainContent, fragments[0])
        .add(R.id.mainContent, fragments[1])
        .commit();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    viewPager = (ViewPager) findViewById(R.id.pager);
    PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(adapter);

    viewPager.setOnPageChangeListener(this);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    ActionBar.Tab tab = actionBar.newTab().setText("Flash").setTabListener(this);
    actionBar.addTab(tab);

    tab = actionBar.newTab().setText("Supeman").setTabListener(this);
    actionBar.addTab(tab);
  }
Beispiel #13
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ParseAnalytics.trackAppOpenedInBackground(getIntent());

    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser == null) {
      navigateToLogin();
    } else {
      Log.i(TAG, currentUser.getUsername());
    }

    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    Log.d(TAG, "Before new SectionPageAdapter");
    mSectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
    Log.d(TAG, "After new SectionPageAdapter");

    // Set up the ViewPager with the sections adapter.
    Log.d(TAG, "Before findViewById(R.id.pager)");
    mViewPager = (ViewPager) findViewById(R.id.pager);
    Log.d(TAG, "After findViewById(R.id.pager)");
    Log.d(TAG, "Before setAdapter");
    mViewPager.setAdapter(mSectionsPagerAdapter);
    Log.d(TAG, "After setAdapter");

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });
    Log.d(TAG, "Before loop");
    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
    Log.d(TAG, "After loop");
  }
Beispiel #14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ActionBar actionbar = getSupportActionBar();
    actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    actionbar.addTab(
        actionbar.newTab().setText(getString(R.string.title_fragment_list)).setTabListener(this));
    actionbar.addTab(
        actionbar.newTab().setText(getString(R.string.title_fragment_flags)).setTabListener(this));

    FragmentManager manager = getSupportFragmentManager();
    manager
        .beginTransaction()
        .add(R.id.mainContent, fragments[0])
        .add(R.id.mainContent, fragments[1])
        .commit();
  }
 private void specifyActionBar() {
   final String[] tabs = {"Hotels", "Agents"};
   final ActionBar actionBar = getSupportActionBar();
   actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
   for (int i = 0; i < 2; i++) {
     Tab tab = actionBar.newTab();
     tab.setText(tabs[i]);
     tab.setTabListener(this);
     actionBar.addTab(tab);
   }
 }
Beispiel #16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Comm.mainContext = MainActivity.this;

    findViewById(R.id.progress_bar_update).setVisibility(View.GONE);

    Comm.showsInstances = new DBHelper(this, null).loadShowsAll();
    Comm.showsFiltered = Comm.showsInstances;

    if (Comm.showsInstances.size() == 0) {
      Intent intent = new Intent(this, StartActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
      startActivity(intent);
    } else {
      getSupportLoaderManager().initLoader(3, null, this);
    }

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
            if (position == 2) {
              filterView.setVisible(true);
            } else {
              filterView.setVisible(false);
            }
          }
        });

    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    Bundle b = getIntent().getExtras();
    if (b != null) {
      if (b.getBoolean("via_notification", false)) {
        actionBar.setSelectedNavigationItem(1);
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    pm = getPackageManager();

    device = new Device();

    viewPager = (ViewPager) findViewById(R.id.pager);
    actionBar = getSupportActionBar();
    pagerAdapter = new PagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(pagerAdapter);
    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    for (String tab_name : tabs) {
      actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this));
    }

    viewPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {

          @Override
          public void onPageSelected(int position) {
            // on changing the page
            // make respected tab selected
            actionBar.setSelectedNavigationItem(position);
          }

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {}

          @Override
          public void onPageScrollStateChanged(int arg0) {}
        });

    List<PackageInfo> installedApplications =
        pm.getInstalledPackages(PackageManager.GET_PERMISSIONS);
    device.apps = App.scanApps(installedApplications, this.getApplicationContext());
    double sum = 0.0;
    for (App a : device.apps) {
      sum += a.getScore();
    }
    device.setAppScore(sum / device.apps.size());

    device.os = OS.scanOS(android.os.Build.VERSION.RELEASE, getApplicationContext());
    device.setOsScore(device.os.getScore());

    Securitometer securitometer = (Securitometer) getApplicationContext();
    securitometer.setDevice(device);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

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

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            if (actionBar != null) {
              actionBar.setSelectedNavigationItem(position);
            }
          }
        });

    Drawable drawable[] = new Drawable[mSectionsPagerAdapter.getCount()];
    drawable[0] = getResources().getDrawable(R.drawable.icon_tab_cinf);
    drawable[1] = getResources().getDrawable(R.drawable.icon_tab_ns);
    drawable[2] = getResources().getDrawable(R.drawable.icon_tab_ht);
    drawable[3] = getResources().getDrawable(R.drawable.icon_tab_ci);
    drawable[4] = getResources().getDrawable(R.drawable.icon_tab_sg);

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      if (actionBar != null) {
        actionBar.addTab(actionBar.newTab().setTabListener(this).setIcon(drawable[i]));
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.assigned_task_frames);

    Bundle extras = getIntent().getExtras();
    groupName = extras.getString("groupname");
    userName = extras.getString("userName");
    param = new RequestParams();
    param.add("groupname", groupName);
    invokeWSForGettingAssignedTasksToPersons(param, false, false);

    // Put ActionBar in Tab Mode
    tabBar = getSupportActionBar();
    tabBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Store the list of tasks as an argument to the TaskFragment
    Bundle args = new Bundle();
    args.putStringArrayList(TASK_IDS, mTaskIdsStringPending);
    args.putString(GROUP_NAME, groupName);
    args.putString(USER_NAME, userName);
    args.putStringArrayList(PERSON_IDS, mPersonsList);
    pendingFrag.setArguments(args);
    // Configure a tab for the Pending task TaskFragment
    tabBar.addTab(
        tabBar.newTab().setText("Pending tasks").setTabListener(new TabListener(pendingFrag)));

    // Store the list of tasks as an argument to the TaskFragment
    args = new Bundle();
    args.putStringArrayList(TASK_IDS, mTaskIdsStringCompleted);
    args.putString(GROUP_NAME, groupName);
    args.putString(USER_NAME, userName);
    args.putStringArrayList(PERSON_IDS, mPersonsList);
    completedFrag.setArguments(args);
    // Configure a tab for the Completed tasks TaskFragment
    tabBar.addTab(
        tabBar.newTab().setText("Completed tasks").setTabListener(new TabListener(completedFrag)));
  }
  @Override
  public void addTab(TabProxy tabProxy) {
    ActionBar.Tab tab = actionBar.newTab();
    tab.setTabListener(this);

    // Create a view for this tab proxy.
    TiUIActionBarTab actionBarTab = new TiUIActionBarTab(tabProxy, tab);
    tabProxy.setView(actionBarTab);

    // Add the new tab, but don't select it just yet.
    // The selected tab is set once the group is done opening.
    actionBar.addTab(tab, false);
    tabGroupPagerAdapter.notifyDataSetChanged();
    int numTabs = actionBar.getTabCount();
    int offscreen = numTabs > 1 ? numTabs - 1 : 1; // Must be at least 1
    tabGroupViewPager.setOffscreenPageLimit(offscreen);
  }
Beispiel #21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {

      setContentView(R.layout.view_pager);
      actionBar = getSupportActionBar();
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

      mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

      try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
          menuKeyField.setAccessible(true);
          menuKeyField.setBoolean(config, false);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }

      mViewPager = (ViewPager) findViewById(R.id.pager);
      mViewPager.setAdapter(mSectionsPagerAdapter);
      mViewPager.setOnPageChangeListener(
          new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {

              actionBar.setSelectedNavigationItem(position);
              mSectionsPagerAdapter.notifyDataSetChanged();
            }
          });

      for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {

        actionBar.addTab(
            actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
      }

      //      }
    } catch (Exception a) {
    }
  }
Beispiel #22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Extract the "needed products" information sent from the SplashScreen activity
    Intent k = getIntent();
    ProductListFragment.items = k.getExtras().getStringArray("products");

    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

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

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
  }
  private void showReportFragment() {
    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

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

    if (actionBar != null) {
      // For each of the sections in the app, add a tab to the action bar.
      for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar.addTab(
            actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    AppConfig.init(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second_viewpager);

    // ViewPager and its adapters use support library
    // fragments, so use getSupportFragmentManager.
    final ViewPager mViewPager = (ViewPager) findViewById(R.id.pager_id);
    DemoCollectionPagerAdapter mDemoCollectionPagerAdapter =
        new DemoCollectionPagerAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(mDemoCollectionPagerAdapter);

    // -------------------------------------------------------------------------
    // -------------------------------------------------------------------------
    // --------------------- WIDGET TAB LAYOUT STYLE ---------------------------
    // -------------------------------------------------------------------------
    // -------------------------------------------------------------------------

    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setupWithViewPager(mViewPager);

    // Iterate over all tabs and set the custom view
    /*for (int i = 0; i < tabLayout.getTabCount(); i++) {
    	TabLayout.Tab tab = tabLayout.getTabAt(i);
    	tab.setCustomView(mDemoCollectionPagerAdapter.getTabView(i));
    }*/

    // SCROLLING TYPE TABS (FOR UNLIMITED NUMBER OF PAGES) IS DIRECTLY
    // IN THE XML FILES. YOU MUST OVERRIDE getPageTitle METHOD ID THE
    // FRAGMENTPAGERADAPTER IN ORDER TO MAKE IT WORK.

    // -------------------------------------------------------------------------
    // -------------------------------------------------------------------------
    // ------------------------  ACTION BAR TYPE TABS --------------------------
    // -------------------------------------------------------------------------
    // -------------------------------------------------------------------------

    ActionBar actionBar = getSupportActionBar();

    // Specify that tabs should be displayed in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create a tab listener that is called when the user changes tabs.
    ActionBar.TabListener tabListener =
        new ActionBar.TabListener() {
          public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
            // show the given tab
            // When the tab is selected, switch to the
            // corresponding page in the ViewPager.
            mViewPager.setCurrentItem(tab.getPosition());
          }

          public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
            // hide the given tab
          }

          public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
            // probably ignore this event
          }
        };

    // Add 3 tabs, specifying the tab's text and TabListener
    for (int i = 0; i < 3; i++) {
      actionBar.addTab(actionBar.newTab().setText("Tab " + (i + 1)).setTabListener(tabListener));
    }

    mViewPager.addOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            // When swiping between pages, select the
            // corresponding tab.
            getSupportActionBar().setSelectedNavigationItem(position);
          }
        });

    // -------------------------------------------------------------------------
    // -------------------------------------------------------------------------
    // -------------------------------------------------------------------------
    // -------------------------------------------------------------------------
    // -------------------------------------------------------------------------

  }
  // MyDBHandler db;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.subsidy_main);
    // get the reference of the list view
    // ListView listView = (ListView)findViewById(R.id.subsidy_name_listview);
    // set Customize Adapter
    // db = new MyDBHandler(this,null,null,1);
    // set action bar
    //        if (savedInstanceState == null) {
    //            getSupportFragmentManager().beginTransaction()
    //                    .add(R.id.container, new subsidyNameFragment())
    //                    .commit();
    //        }
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // NAVIGATION_MODE_TABS常量表示Tab导航模式
    actionBar.setDisplayShowTitleEnabled(
        true); // 这里的Title显示的是Activity的android:label属性指定的文字,也就是图1中”Google Play”

    ActionBar.Tab tab =
        actionBar
            .newTab()
            .setText("Agricultural Schemes ")
            .setTabListener(
                new CustomTabListener<subsidyNameFragment>(
                    this, "Name", subsidyNameFragment.class));
    actionBar.addTab(tab);
    tab =
        actionBar
            .newTab()
            .setText("Check Eligibility")
            .setTabListener(
                new CustomTabListener<SubsidyEligibilityFragment>(
                    this, "Eligibility", SubsidyEligibilityFragment.class));
    actionBar.addTab(tab);
    tab =
        actionBar
            .newTab()
            .setText("Service Covered")
            .setTabListener(
                new CustomTabListener<SubsidyServiceFragment>(
                    this, "Service", SubsidyServiceFragment.class));
    actionBar.addTab(tab);
    tab =
        actionBar
            .newTab()
            .setText("Enrolling Process")
            .setTabListener(
                new CustomTabListener<SubsidyProcessFragment>(
                    this, "Process", SubsidyProcessFragment.class));
    actionBar.addTab(tab);

    actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#67e194")));

    //        ActionBar.Tab tab = actionBar.newTab().setText("Name").setTabListener(this);
    //        actionBar.addTab(tab);
    //        tab = actionBar.newTab().setText("Eligibility").setTabListener(this);
    //        actionBar.addTab(tab);
    //        tab = actionBar.newTab().setText("Service").setTabListener(this);
    //        actionBar.addTab(tab);
    //        tab = actionBar.newTab().setText("Process").setTabListener(this);
    //        actionBar.addTab(tab);
    actionBar.setTitle("Agriculture Subsidy");
  }
Beispiel #26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActionBar ab = getSupportActionBar();

    if (ab != null) {
      ab.setDisplayOptions(
          ActionBar.DISPLAY_SHOW_TITLE
              | ActionBar.DISPLAY_SHOW_HOME
              | ActionBar.DISPLAY_HOME_AS_UP);
    }

    // Activamos el modo fullscreen
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    fragment_tags = new ArrayList<String>();
    fragment_tags.add("list_fragment");
    fragment_tags.add("images_fragment");
    fragment_tags.add("places_fragment");
    fragment_tags.add("about_fragment");

    setContentView(R.layout.tabs_activity_main);

    fragments[0].setHasOptionsMenu(true);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    actionBar.addTab(
        actionBar
            .newTab()
            .setText(getResources().getString(R.string.listado))
            .setTabListener(this));

    actionBar.addTab(
        actionBar
            .newTab()
            .setText(getResources().getString(R.string.imagenes))
            .setTabListener(this));

    actionBar.addTab(
        actionBar.newTab().setText(getResources().getString(R.string.places)).setTabListener(this));

    actionBar.addTab(
        actionBar
            .newTab()
            .setText(getResources().getString(R.string.acercaDe))
            .setTabListener(this));

    FragmentManager manager = getSupportFragmentManager();
    manager
        .beginTransaction()
        .add(R.id.mainContent2, fragments[0], fragment_tags.get(0))
        .add(R.id.mainContent2, fragments[1], fragment_tags.get(1))
        .add(R.id.mainContent2, fragments[2], fragment_tags.get(2))
        .add(R.id.mainContent2, fragments[3], fragment_tags.get(3))
        .commit();
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
      Date date = new Date();
      SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
      sdf.setTimeZone(TimeZone.getTimeZone("EST5EDT"));
      String now = sdf.format(date);

      prefs = getSharedPreferences(prefName, MODE_PRIVATE);
      SharedPreferences.Editor editor = prefs.edit();
      editor.putString(ACTIVE_KEY, now);
      editor.commit();
      db = new TableDbAdapter(getApplicationContext());

      try {
        if (getIntent().getExtras().getString("type").equals("usercheck")) {
          Toast.makeText(
                  getBaseContext(),
                  "Welcome back, " + prefs.getString(KEY_USERNAME, "") + "!",
                  Toast.LENGTH_SHORT)
              .show();
        }
      } catch (NullPointerException e) {
        // TODO: handle exception
        e.printStackTrace();
      }
    }

    setContentView(R.layout.main);

    actionBar = getSupportActionBar();

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    if (metrics.heightPixels < 400 && metrics.widthPixels < 300) {
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setDisplayShowHomeEnabled(false);
    } else {
      actionBar.setDisplayUseLogoEnabled(true);
    }

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    ActionBar.Tab tabCalendar = actionBar.newTab().setText("Calendar");
    ActionBar.Tab tabTotals = actionBar.newTab().setText("Totals");
    ActionBar.Tab tabDetails = actionBar.newTab().setText("User Info");

    Fragment fragmentCalendar = new FragmentCalendar();
    Fragment fragmentTotals = new FragmentTotals();
    Fragment fragmentDetails = new FragmentDetails();

    tabCalendar.setTabListener(new MyTabsListener(fragmentCalendar));
    tabTotals.setTabListener(new MyTabsListener(fragmentTotals));
    tabDetails.setTabListener(new MyTabsListener(fragmentDetails));

    actionBar.addTab(tabCalendar);
    actionBar.addTab(tabTotals);
    actionBar.addTab(tabDetails);
  }