Пример #1
0
  private void initCircularActionMenu(FloatingActionButton fab) {
    SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this);

    ImageView itemIcon1 = new ImageView(this);
    itemIcon1.setImageDrawable(getResources().getDrawable(R.drawable.ic_whatshot_white_48dp));
    SubActionButton button1 =
        itemBuilder
            .setContentView(itemIcon1)
            .setBackgroundDrawable(
                getResources().getDrawable(R.drawable.navigation_button_background))
            .build();
    button1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mActionMenu.close(true);
            onNavigationItemID(R.id.nav_guidance);
            mNavigationView.setCheckedItem(R.id.nav_guidance);
          }
        });

    ImageView itemIcon2 = new ImageView(this);
    itemIcon2.setImageDrawable(getResources().getDrawable(R.drawable.ic_star_white_48dp));
    SubActionButton button2 =
        itemBuilder
            .setContentView(itemIcon2)
            .setBackgroundDrawable(
                getResources().getDrawable(R.drawable.navigation_button_background))
            .build();
    button2.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mActionMenu.close(true);
            onNavigationItemID(R.id.nav_favorite);
            mNavigationView.setCheckedItem(R.id.nav_favorite);
          }
        });

    ImageView itemIcon3 = new ImageView(this);
    itemIcon3.setImageDrawable(
        getResources().getDrawable(R.drawable.ic_format_list_bulleted_white_48dp));
    SubActionButton button3 =
        itemBuilder
            .setContentView(itemIcon3)
            .setBackgroundDrawable(
                getResources().getDrawable(R.drawable.navigation_button_background))
            .build();
    button3.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mActionMenu.close(true);
            onNavigationItemID(R.id.nav_all_boards);
            mNavigationView.setCheckedItem(R.id.nav_all_boards);
          }
        });

    ImageView itemIcon4 = new ImageView(this);
    itemIcon4.setImageDrawable(getResources().getDrawable(R.drawable.ic_email_white_48dp));
    SubActionButton button4 =
        itemBuilder
            .setContentView(itemIcon4)
            .setBackgroundDrawable(
                getResources().getDrawable(R.drawable.navigation_button_background))
            .build();
    button4.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mActionMenu.close(true);
            onNavigationItemID(R.id.nav_mail);
            mNavigationView.setCheckedItem(R.id.nav_mail);
          }
        });

    mActionMenu =
        new FloatingActionMenu.Builder(this)
            .addSubActionView(button1)
            .addSubActionView(button2)
            .addSubActionView(button3)
            .addSubActionView(button4)
            .attachTo(fab)
            .build();
  }
Пример #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.app_bar);
    mTabs = (SlidingTabLayout) findViewById(R.id.tabs);
    mPager = (ViewPager) findViewById(R.id.pager);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    NavigationDrawerFragment drawerFragment =
        (NavigationDrawerFragment)
            getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
    drawerFragment.setUp((DrawerLayout) findViewById(R.id.drawer_layout), toolbar);

    mPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));

    mTabs.setDistributeEvenly(true);

    mTabs.setViewPager(mPager);

    ImageView imageView = new ImageView(this);
    imageView.setImageResource(R.drawable.plus);
    FloatingActionButton actionButton =
        new FloatingActionButton.Builder(this)
            .setContentView(imageView)
            .setBackgroundDrawable(R.drawable.button_action_red)
            .build();

    ImageView videoIcon = new ImageView(this);
    videoIcon.setImageResource(R.drawable.video);

    ImageView galleryIcon = new ImageView(this);
    galleryIcon.setImageResource(R.drawable.gallery);

    ImageView audioIcon = new ImageView(this);
    audioIcon.setImageResource(R.drawable.audio);

    SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this);

    SubActionButton buttonVideo = itemBuilder.setContentView(videoIcon).build();
    SubActionButton buttonGallery = itemBuilder.setContentView(galleryIcon).build();
    SubActionButton buttonAudio = itemBuilder.setContentView(audioIcon).build();

    FloatingActionMenu actionMenu =
        new FloatingActionMenu.Builder(this)
            .addSubActionView(buttonVideo)
            .addSubActionView(buttonGallery)
            .addSubActionView(buttonAudio)
            .attachTo(actionButton)
            .build();

    buttonGallery.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent, "select picture"), 1);
            Toast.makeText(Login.this, "Done....", Toast.LENGTH_SHORT).show();
          }
        });
    buttonVideo.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(), VideoPlay.class));
          }
        });
  }