예제 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar to show a dropdown list.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    final String[] dropdownValues = getResources().getStringArray(R.array.dropdown);

    // Specify a SpinnerAdapter to populate the dropdown list.
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(
            actionBar.getThemedContext(),
            android.R.layout.simple_spinner_item,
            android.R.id.text1,
            dropdownValues);

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    // Set up the dropdown list navigation in the action bar.
    actionBar.setListNavigationCallbacks(adapter, this);

    // use getActionBar().getThemedContext() to ensure
    // that the text color is always appropriate for the action bar
    // background rather than the activity background.
  }
 @Override
 public Context getActionBarThemedContext() {
   final ActionBar actionBar = mActivity.getActionBar();
   final Context context;
   if (actionBar != null) {
     context = actionBar.getThemedContext();
   } else {
     context = mActivity;
   }
   return context;
 }
예제 #3
0
  private void initListNav() {
    ArrayList<String> items = new ArrayList<String>();
    ArrayAdapter<String> nav = null;
    ActionBar bar = getActionBar();

    for (int type : MAP_TYPE_NAMES) {
      items.add(getString(type));
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      nav =
          new ArrayAdapter<String>(
              bar.getThemedContext(), android.R.layout.simple_spinner_item, items);
    } else {
      nav = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items);
    }

    nav.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    bar.setListNavigationCallbacks(nav, this);
  }
예제 #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar to show a dropdown list.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // Set up the dropdown list navigation in the action bar.
    actionBar.setListNavigationCallbacks(
        // Specify a SpinnerAdapter to populate the dropdown list.
        new ArrayAdapter<String>(
            actionBar.getThemedContext(),
            android.R.layout.simple_list_item_1,
            android.R.id.text1,
            new String[] {
              getString(R.string.title_section1),
              getString(R.string.title_section2),
              getString(R.string.title_section3),
            }),
        this);

    //
    Display display = getWindowManager().getDefaultDisplay();
    DisplayMetrics dm = new DisplayMetrics();
    display.getMetrics(dm);
    System.setProperty("width", String.valueOf(dm.widthPixels));
    System.setProperty("height", String.valueOf(dm.heightPixels));

    if (System.getProperty("init") == null) {
      System.setProperty("init", "1");
      Intent intent = new Intent(getApplicationContext(), PrototypeActivity.class);
      intent.putExtra(PrototypeActivity.ACTION, "init");
      intent.putExtra(PrototypeActivity.ORDER, 0);
      startActivity(intent);
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final LinearLayout mLayoutRoot =
        (LinearLayout) inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
    mDrawerListView = (ListView) mLayoutRoot.findViewById(R.id.headerListView);
    this.controlsList = (ListView) mLayoutRoot.findViewById(R.id.controlsList);
    this.controlsList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectNavigationDrawerControl(position);
          }
        });

    mDrawerListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectNavigationDrawerSection(position);
          }
        });

    this.controlsList.setAdapter(new NavigationDrawerExamplesListAdapter(this.getActivity(), 0));

    mDrawerListView.setAdapter(
        new ArrayAdapter<String>(
            actionBar.getThemedContext(),
            R.layout.drawer_list_item_container,
            R.id.drawerItemTextView,
            new String[] {
              getString(R.string.homeString),
              getString(R.string.favoritesStringPascalCase),
              getString(R.string.aboutString)
            }));
    mDrawerListView.setItemChecked(mCurrentNavigationDrawerSection, true);
    return mLayoutRoot;
  }
예제 #6
0
  /**
   * Creates a set of {@link ActionBar} navigation items for the given string resource IDs.
   *
   * <p>This implementation employs {@link ActionBar#NAVIGATION_MODE_LIST}.
   *
   * @param navigationResourceIds the array of String resource IDs for the navigation item titles
   * @since 1.1.0
   */
  protected void addNavigationItems(final int... navigationResourceIds) {

    ActionBar actionBar = getActionBar();

    if (actionBar != null) {

      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

      this.navigationResourceIds = navigationResourceIds;
      String[] stringResources = new String[navigationResourceIds.length];

      for (int i = 0; i < navigationResourceIds.length; i++) {

        stringResources[i] = getString(navigationResourceIds[i]);
      }

      ArrayAdapter<String> adapter =
          NavigationAdapter.newInstance(
              actionBar.getThemedContext(),
              R.layout.action_view_title_repo,
              android.R.id.text1,
              android.R.layout.simple_spinner_dropdown_item,
              accountService.getGitHubUsername(this),
              stringResources);

      actionBar.setListNavigationCallbacks(
          adapter,
          new ActionBar.OnNavigationListener() {

            @Override
            public boolean onNavigationItemSelected(int itemPosition, long itemId) {

              onTabSelected(navigationResourceIds[itemPosition]);
              return true;
            }
          });
    }
  }
예제 #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    if (hasTwoCameras) {
      final ActionBar actionBar = getActionBar();

      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

      ArrayAdapter<CharSequence> adapter =
          ArrayAdapter.createFromResource(
              actionBar.getThemedContext(), R.array.nav, android.R.layout.simple_list_item_1);

      actionBar.setListNavigationCallbacks(adapter, this);
    } else {
      current = DemoCameraFragment.newInstance(false);

      getFragmentManager().beginTransaction().replace(R.id.container, current).commit();
    }
  }
 @Override
 public Context getThemedContext() {
   return mActionBar.getThemedContext();
 }
예제 #9
0
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    // requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    super.onCreate(savedInstanceState);

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

    setContentView(R.layout.activity_home);

    final ActionBar actionBar = getActionBar();
    //
    // if (android.os.Build.VERSION.SDK_INT < 11) {
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    // }
    actionBar.setHomeButtonEnabled(false);

    actionBar.setIcon(R.drawable.ic_list);

    actionBar.setDisplayOptions(actionBar.getDisplayOptions() | ActionBar.DISPLAY_SHOW_CUSTOM);
    ImageView imageView = new ImageView(actionBar.getThemedContext());
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    imageView.setImageResource(R.drawable.ic_list);
    ActionBar.LayoutParams layoutParams =
        new ActionBar.LayoutParams(
            ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT,
            Gravity.LEFT | Gravity.CENTER_VERTICAL);

    // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    //
    // firstTab = actionBar.newTab().setIcon(R.drawable.ic_launcher)
    // .setText("First Tab");
    // secondTab = actionBar.newTab().setIcon(R.drawable.ic_launcher)
    // .setText("Second Tab");
    // thirdTab = actionBar.newTab().setIcon(R.drawable.ic_launcher)
    // .setText("Third Tab");
    //
    // /*
    // * firstTab.setTabListener(new TabListener(firstFragmentTab));
    // * secondTab.setTabListener(new TabListener(secondFragmentTab));
    // * thirdTab.setTabListener(new TabListener(thirdFragmentTab));
    // */
    //
    // actionBar.addTab(firstTab);
    // actionBar.addTab(secondTab);
    // actionBar.addTab(thirdTab);
    //
    // viewPager = (ViewPager) findViewById(R.id.pager);
    // List<Fragment> fragments = getFragments();
    //
    // obj_pagerAdapter = new TabsPagerAdapter(getSupportFragmentManager(),
    // fragments);
    //
    // ViewPager pager = (ViewPager) findViewById(R.id.pager);
    //
    // pager.setAdapter(obj_pagerAdapter);

    analytics = GoogleAnalytics.getInstance(this);
    analytics.setLocalDispatchPeriod(1800);

    tracker = analytics.newTracker("UA-66147419-1"); // Replace with actual
    // tracker/property
    // Id

    tracker.enableExceptionReporting(true);
    tracker.enableAdvertisingIdCollection(true);
    tracker.enableAutoActivityTracking(true);

    tracker.setScreenName("main screen");

    tracker.send(
        new HitBuilders.EventBuilder()
            .setCategory("UX")
            .setAction("click")
            .setLabel("submit")
            .build());

    viewPager = (ViewPager) findViewById(R.id.pager);
    // actionBar = getActionBar();
    mAdapter = new TabsPagerAdapter(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) {
            actionBar.setSelectedNavigationItem(position);
            easyTracker = EasyTracker.getInstance();
          }

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

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

    imgBtnList = (ImageView) findViewById(R.id.imgBtn_list);
    arraylist_Drawer = new ArrayList<String>();
    drawer = (ListView) findViewById(R.id.left_drawer);
    mydrawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    ArrayAdapter<String> adpt =
        new ArrayAdapter<String>(
            HomeActivity.this, android.R.layout.simple_list_item_1, navMenuTitles);

    drawer.setAdapter(adpt);

    imgBtnList.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            mydrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

            if (mydrawer.isDrawerOpen(drawer)) {
              // Animation animation1 = AnimationUtils.loadAnimation(
              // getApplicationContext(), R.anim.clockwise);

              // imgBtnList.startAnimation(animation1);

              mydrawer.closeDrawer(drawer);
              // imgBtnList.setBackgroundResource(R.drawable.ic_list);

            } else {
              // Animation animation2 = AnimationUtils.loadAnimation(
              // getApplicationContext(), R.anim.clockwise);
              // imgBtnList.startAnimation(animation2);
              mydrawer.openDrawer(drawer);
              // imgBtnList.setBackgroundResource(R.drawable.img_back);
            }
          }
        });
  }
예제 #10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set up the action bar to show a dropdown list.
    actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // Set up the dropdown list navigation in the action bar.
    String[] titles = NavigationHelper.getTitles();
    actionBar.setListNavigationCallbacks(
        // Specify a SpinnerAdapter to populate the dropdown list.
        new ArrayAdapter<String>(
            actionBar.getThemedContext(),
            R.layout.navigation_list_item,
            android.R.id.text1,
            titles),
        this);

    mPagerTitle = getPagerTitle();
    initFlickerAnimations();

    mPagerTitleHander =
        new Handler() {
          @Override
          public void handleMessage(Message msg) {

            switch (msg.what) {
              case 1: // init show
                sendEmptyMessage(3);
                sendEmptyMessageDelayed(2, 2000);
                break;
              case 2: // hide page title
                if (isShowTitle && autoHide) {
                  mPagerTitle.startAnimation(hideAnim);
                }
                break;
              case 3: // show page title
                if (!isShowTitle) {
                  isShowTitle = true;
                  ViewParent parent = mPagerTitle.getParent();
                  if (parent == null) {
                    // mViewPager.addView( mPagerTitle,
                    // LayoutParams.MATCH_PARENT,
                    // LayoutParams.WRAP_CONTENT);
                    mViewPager.addView(mPagerTitle);
                    mPagerTitle.startAnimation(showAnim);
                  }
                }
                break;
            }
          };
        };

    mPagerTitleHander.sendEmptyMessageDelayed(1, 100);
    mViewPager.setOnPageChangeListener(
        new OnPageChangeListener() {
          @Override
          public void onPageSelected(int pos) {
            actionBar.setSelectedNavigationItem(pos);
            onPageChanged(pos);
          }

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

          @Override
          public void onPageScrollStateChanged(int state) {
            Log.d("TestData", "onPageScrollStateChanged state:" + state);
            if (state == ViewPager.SCROLL_STATE_DRAGGING) {
              mPagerTitleHander.removeMessages(2);
              if (autoHide) mPagerTitleHander.sendEmptyMessage(3);
            } else if (state == ViewPager.SCROLL_STATE_IDLE) {
              mPagerTitleHander.sendEmptyMessageDelayed(2, 2000);
            }
          }
        });
  }