Exemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contact_mail); // needed?
    // implement action bar
    ActionBar aBar = getActionBar();
    aBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    aBar.setDisplayHomeAsUpEnabled(true);

    // friend tab
    String lab1 = getResources().getString(R.string.friends); // what do i id?
    Tab tab = aBar.newTab();
    tab.setText(lab1);
    TabListener<friendFrag> friFrag = new TabListener<friendFrag>(this, lab1, friendFrag.class);
    tab.setTabListener(friFrag);
    aBar.addTab(tab);

    // mail tab
    String lab2 = getResources().getString(R.string.mail);
    tab = aBar.newTab();
    tab.setText(lab2);
    TabListener<mailFrag> mFrag = new TabListener<mailFrag>(this, lab2, mailFrag.class);
    tab.setTabListener(mFrag);
    aBar.addTab(tab);
  }
Exemplo n.º 2
0
  private void intiActionTab() {
    actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    tab_top = actionBar.newTab().setText("头条");
    tab_cyclopedia = actionBar.newTab().setText("百科");
    tab_message = actionBar.newTab().setText("资讯");
    tab_manage = actionBar.newTab().setText("经营");
    tab_data = actionBar.newTab().setText("数据");

    tab_top.setTabListener(this);
    tab_cyclopedia.setTabListener(this);
    tab_message.setTabListener(this);
    tab_manage.setTabListener(this);
    tab_data.setTabListener(this);

    actionBar.addTab(tab_top);
    actionBar.addTab(tab_cyclopedia);
    actionBar.addTab(tab_message);
    actionBar.addTab(tab_manage);
    actionBar.addTab(tab_data);
  }
  public void setUpGUI() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    String tab1 = getResources().getString(R.string.label1);
    String tab2 = getResources().getString(R.string.label2);
    String tab3 = getResources().getString(R.string.label3);

    Tab tab =
        actionBar
            .newTab()
            .setText(tab1)
            .setTabListener(new TabListener<CurrentFragment>(this, tab1, CurrentFragment.class));
    actionBar.addTab(tab, 0, curTab == 0);

    tab =
        actionBar
            .newTab()
            .setText(tab2)
            .setTabListener(new TabListener<NearbyFragment>(this, tab2, NearbyFragment.class));
    actionBar.addTab(tab, 1, curTab == 1);

    tab =
        actionBar
            .newTab()
            .setText(tab3)
            .setTabListener(new TabListener<AllFragment>(this, tab3, AllFragment.class));
    actionBar.addTab(tab, 2, curTab == 2);
  }
Exemplo n.º 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);

    bargain_user = (User) getIntent().getSerializableExtra("USER_PROFILE");
    user_deal_data = FeedActivity.user_deal_data;
    user_like_data = FeedActivity.user_like_data;

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

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

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

    // naming the tabs of the ActionBar
    actionBar.addTab(actionBar.newTab().setText(R.string.title_profile).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(R.string.title_liked_deals).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(R.string.my_deals).setTabListener(this));

    mViewPager.setAdapter(mAppSectionsPagerAdapter);
  }
  private void initializeBrowseTabs() {
    ActionBar actionBar = getActivity().getActionBar();
    TabListener listener = getTabListener();
    // Initialize Featured Tab	position=1
    Tab actionBarTab = actionBar.newTab().setTabListener(listener);
    actionBarTab.setIcon(
        new IconDrawable(getActivity(), IconValue.fa_film)
            .colorRes(R.color.actionbar_tab_text)
            .actionBarSize());
    actionBar.addTab(actionBarTab);

    // Initialize Varieties Tab	position=2
    actionBarTab = actionBar.newTab().setTabListener(listener);
    actionBarTab.setIcon(
        new IconDrawable(getActivity(), IconValue.fa_th_large)
            .colorRes(R.color.actionbar_tab_text)
            .actionBarSize());
    actionBar.addTab(actionBarTab);

    // Initialize All Tab	position=3
    actionBarTab = actionBar.newTab().setTabListener(listener);
    actionBarTab.setIcon(
        new IconDrawable(getActivity(), IconValue.fa_archive)
            .colorRes(R.color.actionbar_tab_text)
            .actionBarSize());
    actionBar.addTab(actionBarTab);
  }
Exemplo n.º 6
0
  private void InitActionBar() {
    MyTabListener mtabListener = new MyTabListener();

    mActionBar = getActionBar();
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mActionBar.addTab(mActionBar.newTab().setText("Topic").setTabListener(mtabListener));
    mActionBar.addTab(mActionBar.newTab().setText("Question").setTabListener(mtabListener));
    mActionBar.addTab(mActionBar.newTab().setText("Sample").setTabListener(mtabListener));
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setTitle("Search");
  }
Exemplo n.º 7
0
  private void addTabs() {
    ActionBar.Tab addNewExpenseTab = actionBar.newTab();
    addNewExpenseTab.setTabListener(this);
    addNewExpenseTab.setText("Add New");
    actionBar.addTab(addNewExpenseTab);

    ActionBar.Tab todayTab = actionBar.newTab();
    todayTab.setTabListener(this);
    todayTab.setText("Today");
    actionBar.addTab(todayTab);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_fragment_tabs);

    // Add 3 tabs which will switch fragments
    ActionBar ab = getActionBar();
    ab.addTab(ab.newTab().setText("Tab 1").setTabListener(this));
    ab.addTab(ab.newTab().setText("Tab 2").setTabListener(this));
    ab.addTab(ab.newTab().setText("Tab 3").setTabListener(this));
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  }
Exemplo n.º 9
0
  public void attachTabs(ActionBar bar) {
    TabListener tl = new TabListener(this, this);

    Tab tab1 = bar.newTab();
    tab1.setText("Tab1");
    tab1.setTabListener(tl);
    bar.addTab(tab1);

    Tab tab2 = bar.newTab();
    tab2.setText("Tab2");
    tab2.setTabListener(tl);
    bar.addTab(tab2);
  }
Exemplo n.º 10
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // set up actionbar to show tabs
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // add tabs
    actionBar.addTab(actionBar.newTab().setText(R.string.make_tag).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(R.string.my_tags).setTabListener(this));
  }
Exemplo n.º 11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar to show tabs.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // For each of the sections in the app, add a tab to the action bar.
    actionBar.addTab(actionBar.newTab().setText(R.string.title_section1).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(R.string.title_section2).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(R.string.title_section3).setTabListener(this));
  }
  private void buildActionBarAndViewPagerTitles() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(getString(R.string.detail));

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    actionBar.addTab(
        actionBar.newTab().setText(getString(R.string.weibo)).setTabListener(tabListener));

    actionBar.addTab(
        actionBar.newTab().setText(getString(R.string.comments)).setTabListener(tabListener));
    actionBar.addTab(
        actionBar.newTab().setText(getString(R.string.repost)).setTabListener(tabListener));
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActionBar actionBar = getActivity().getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    if (actionBar.getTabCount() != 3) {
      ActionBar.TabListener tabListener =
          new ActionBar.TabListener() {
            @Override
            public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
              // setCurrentItem(tab.getPosition());
              int position = tab.getPosition();
              if (position == 0) {
                fragmentTransaction.replace(R.id.frame_layout, dailyFrag);
              } else if (position == 1) {
                fragmentTransaction.replace(R.id.frame_layout, weeklyFrag);
              } else if (position == 2) {
                fragmentTransaction.replace(R.id.frame_layout, monthlyFrag);
              }
            }

            @Override
            public void onTabUnselected(
                ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
              // No special actions.
            }

            @Override
            public void onTabReselected(
                ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
              // User selected the already selected tab. In this case do nothing.
            }
          };
      ActionBar.Tab tabDaily =
          actionBar.newTab().setText(R.string.history_daily).setTabListener(tabListener);
      ActionBar.Tab tabWeekly =
          actionBar.newTab().setText(R.string.history_weekly).setTabListener(tabListener);
      ActionBar.Tab tabMonthly =
          actionBar.newTab().setText(R.string.history_monthly).setTabListener(tabListener);

      actionBar.removeAllTabs();
      actionBar.addTab(tabDaily);
      actionBar.addTab(tabWeekly);
      actionBar.addTab(tabMonthly);
    }
  }
Exemplo n.º 14
0
 private void initTabs() {
   listingListener =
       new TabListener<ListingListFragment>(this, "listinglist", ListingListFragment.class);
   ActionBar.Tab tab = actionBar.newTab().setText("Listings").setTabListener(listingListener);
   actionBar.addTab(tab);
   tab =
       actionBar
           .newTab()
           .setText("Requests")
           .setTabListener(
               new TabListener<RequestListFragment>(
                   this, "requestlist", RequestListFragment.class));
   actionBar.addTab(tab);
   myListingFrag = (ListingListFragment) listingListener.getFragment();
   myListingFrag.setClient(myClient);
 }
Exemplo n.º 15
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_attention);
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    final ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

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

    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
      actionBar.addTab(
          actionBar
              .newTab()
              .setText(mAppSectionsPagerAdapter.getPageTitle(i))
              .setTabListener(this));
    }
  }
Exemplo n.º 16
0
  public void onCreate(Bundle savedBundle) {
    super.onCreate(savedBundle);
    setContentView(R.layout.dalevents);

    getActionBar().setIcon(R.drawable.ic_launcher);

    viewPager = (ViewPager) findViewById(R.id.adminpager);
    actionBar = getActionBar();
    mAdapter = new ClientTabsPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(mAdapter);
    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 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) {}
        });
  }
Exemplo n.º 17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    String Language = preferences.getString("Lang", "no_find");
    Locale mylocale = new Locale(Language);
    if (Language == "no_find") mylocale = Resources.getSystem().getConfiguration().locale;
    Resources res1 = getResources();
    Configuration conf = res1.getConfiguration();
    conf.locale = mylocale;
    DisplayMetrics dm = res1.getDisplayMetrics();
    res1.updateConfiguration(conf, dm);
    Locale.setDefault(mylocale);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    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));
    }

    // initializes the control object which serves as the interface between the gui and
    // the usb communication
    control = (Control) getLastCustomNonConfigurationInstance();
    if (control == null) {
      Resources res = getResources();
      String[] commands = res.getStringArray(R.array.command_select_options);
      control = new Control();
      Control.initialize(commands);
    }

    //        launchAboutActivity();
  }
Exemplo n.º 18
0
 public void onAddTab(View v) {
   final ActionBar bar = getActionBar();
   final int tabCount = bar.getTabCount();
   final String text = "Tab " + tabCount;
   bar.addTab(
       bar.newTab().setText(text).setTabListener(new TabListener(new TabContentFragment(text))));
 }
  /** Adds tabs below the action bar. */
  private void addTabs() {
    viewPager = (ViewPager) findViewById(R.id.pager_main);
    actionBar = getActionBar();
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

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

    // temp fix, to make sure that PATHAlerts isn't refreshing all the time
    viewPager.setOffscreenPageLimit(4);

    // Adding 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) {}
        });
  }
Exemplo n.º 20
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    viewPager = (ViewPager) getActivity().findViewById(R.id.pager);
    actionBar = getActivity().getActionBar();
    mAdapter = new Course1Adapter(getActivity().getSupportFragmentManager());
    viewPager.setAdapter(mAdapter);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

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

    viewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {

          @Override
          public void onPageSelected(int position) {

            // on Page change, that particular page should be selected
            actionBar.setSelectedNavigationItem(position);
          }

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

          @Override
          public void onPageScrollStateChanged(int position) {}
        });
  }
Exemplo n.º 21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "setting selected id from intent");
    setSelectedItemIDFromIntent();
    ActiveUser activeUser = ((GiveOrTakeApplication) getApplication()).getActiveUser();
    if (activeUser == null || activeUser.getUserID() == null) {
      Intent logoutIntent = new Intent(this, LoginActivity.class);
      logoutIntent.putExtra(LoginFragment.EXTRA_LOGIN_ACTION, LoginFragment.LOGOUT);
      logoutIntent.putExtra(MainActivity.EXTRA_ITEM_ID, getSelectedItemID());
      startActivity(logoutIntent);
      finish();
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

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

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    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))
              .setIcon(mSectionsPagerAdapter.getPageIcon(i))
              .setTabListener(this));
    }

    actionBar.selectTab(actionBar.getTabAt(DEFAULT_SELECTED_TAB));

    Long itemID = getSelectedItemID();
    if (itemID != null) {
      actionBar.selectTab(actionBar.getTabAt(FREE_ITEMS_TAB));
    }
  }
Exemplo n.º 22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    this.context = getApplicationContext();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar.
    // setup action bar for tabs
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(false);

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

    // 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);
          }
        });

    actionBar.addTab(
        actionBar
            .newTab()
            .setText(mSectionsPagerAdapter.getPageTitle(0))
            .setTabListener(new TabListener<Feed>(this, "", Feed.class)));
    actionBar.addTab(
        actionBar
            .newTab()
            .setText(mSectionsPagerAdapter.getPageTitle(1))
            .setTabListener(new TabListener<Circles>(this, "", Circles.class)));
    actionBar.addTab(
        actionBar
            .newTab()
            .setText(mSectionsPagerAdapter.getPageTitle(2))
            .setTabListener(new TabListener<Profile>(this, "", Profile.class)));
  }
Exemplo n.º 23
0
 public void Add(String _title, View _panel, View _customTabView) {
   ActionBar.Tab tab = CreateTab(_title, _panel);
   _customTabView.setVisibility(View.VISIBLE);
   tab.setCustomView(_customTabView); // This overrides values set by setText(CharSequence) and
   // setIcon(Drawable).
   ActionBar actionBar = this.controls.activity.getActionBar();
   actionBar.addTab(tab, false);
 }
Exemplo n.º 24
0
 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
  protected void handleResult(String jsonStr) {
    if (this.actioncode == 17) {
      try {
        JSONObject json = new JSONObject(jsonStr);
        if (json != null) {
          JSONArray jsonarray = json.getJSONArray("housebuilddata");
          for (int i = 0; i < jsonarray.length(); i++) {
            JSONObject rec = jsonarray.getJSONObject(i);
            JSONArray jarrayname = rec.getJSONArray("basebuildingflag");
            for (int j = 0; j < jarrayname.length(); j++) {
              aryBasicBuildingFlag[j] = jarrayname.getString(j).toString();
            }
            JSONArray jarrayname2 = rec.getJSONArray("militarybuildingflag");
            for (int y = 0; y < jarrayname2.length(); y++) {
              aryMilitaryBuildingFlag[y] = jarrayname2.getString(y).toString();
            }
          }
        }
      } catch (JSONException e) {
        for (int i = 0; i < 4; i++) {
          aryBasicBuildingFlag[i] = "0";
        }
        for (int i = 0; i < 8; i++) {
          aryMilitaryBuildingFlag[i] = "0";
        }
      }
      release();

      final ActionBar actionBar = getActionBar();
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
      actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

      actionBar.addTab(
          actionBar
              .newTab()
              .setText("基本建筑")
              .setTabListener(new TabListener(new BaseInfoShowTabContentFragment())));

      actionBar.addTab(
          actionBar
              .newTab()
              .setText("军事建筑")
              .setTabListener(new TabListener(new MilitaryInfoShowTabContentFragment())));
    }
  }
Exemplo n.º 26
0
  public void workwithTabbedActionBar() {
    ActionBar bar = this.getActionBar();
    bar.setTitle(tag);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    TabListener tl = new TabListener(this, this);

    Tab tab1 = bar.newTab();
    tab1.setText("Tab1");
    tab1.setTabListener(tl);
    bar.addTab(tab1);

    Tab tab2 = bar.newTab();
    tab2.setText("Tab2");
    tab2.setTabListener(tl);
    bar.addTab(tab2);
  }
Exemplo n.º 27
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // add necessary intent values to be matched.
    mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
    mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
    mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
    mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);

    // Initialise LocalServiceReciever
    mLIntentFilter.addAction(SocketService.UPDATE_LIST);
    mLReciever =
        new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
            updateMap();
          }
        };

    // Initialise
    mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
    mChannel = mManager.initialize(this, getMainLooper(), null);

    // Initialise
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mActionBar = getActionBar();
    mAdaptor = new TabsPagerAdaptor(getFragmentManager());

    // Set the Tabs Pager
    mViewPager.setAdapter(mAdaptor);
    mActionBar.setHomeButtonEnabled(false);
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Add tabs
    for (int i = 0; i < mAdaptor.getCount(); i++) {
      mActionBar.addTab(mActionBar.newTab().setText(mAdaptor.getPageTitle(i)).setTabListener(this));
    }

    // Bind to SocketService
    bindSocketService();

    // ensure that tabs work
    mViewPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            mActionBar.setSelectedNavigationItem(position);
          }

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

          @Override
          public void onPageScrollStateChanged(int index) {}
        });
  }
Exemplo n.º 28
0
 // This method adds a tab for use in tabbed navigation mode
 public void Add(String _title, View _panel, String _iconIdentifier) {
   ActionBar.Tab tab = CreateTab(_title, _panel);
   if (!_iconIdentifier.equals("")) {
     tab.setIcon(
         GetDrawableResourceById(GetDrawableResourceId(_iconIdentifier))); // _iconIdentifier
   }
   ActionBar actionBar = this.controls.activity.getActionBar();
   actionBar.addTab(tab, false);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    for (int i = 1; i <= 3; i++) {
      ActionBar.Tab tab = actionBar.newTab().setText("Tab#" + i).setTabListener(this);
      actionBar.addTab(tab);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fourth_task_android);

    applicationObject = (ApplicationObject) getApplication();

    fragmentManager = getFragmentManager();
    fragmentManager.addOnBackStackChangedListener(new SmartBackStackListener());

    localBroadcastManager = LocalBroadcastManager.getInstance(FourthTaskAndroid.this);
    broadcastReceiver = new WeatherChangesBroadcastReceiver();

    // Specify that we will be displaying tabs in the action bar
    actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.addTab(
        actionBar.newTab().setText(getString(R.string.label_list)).setTabListener(this));
    actionBar.addTab(
        actionBar.newTab().setText(getString(R.string.label_map)).setTabListener(this));
  }