android.widget.Toolbar Java Examples

The following examples show how to use android.widget.Toolbar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenericActivity.java    From MonsterHunter4UDatabase with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);

    if (fragment == null) {
        fragment = createFragment();
        fm.beginTransaction().add(R.id.fragment_container, fragment)
                .commit();
    }

    // Integrate Toolbar so sliding drawer can go over toolbar
    android.support.v7.widget.Toolbar mtoolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(mtoolbar);

    setTitle(R.string.app_name);
    super.setupDrawer(); // Needs to be called after setContentView
    // Disabled by request. Turns into BACK button
    //super.enableDrawerIndicator(); // Enable drawer toggle button
}
 
Example #2
Source File: PictureActivity.java    From Tweetin with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ViewUnit.setCustomTheme(this);
    setContentView(R.layout.picture);

    Toolbar toolbar = (Toolbar) findViewById(R.id.picture_toolbar);
    ViewCompat.setElevation(toolbar, ViewUnit.getElevation(this, 2));

    setActionBar(toolbar);
    getActionBar().setTitle(getString(R.string.picture_label));
    getActionBar().setDisplayHomeAsUpEnabled(true);

    tweet = (new TweetUnit(this)).getTweetFromIntent(getIntent());

    pictureFragment = (PictureFragment) getSupportFragmentManager().findFragmentById(R.id.picture_fragment);
}
 
Example #3
Source File: SearchActivity.java    From Tweetin with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ViewUnit.setCustomTheme(this);
    setContentView(R.layout.search);

    Toolbar toolbar = (Toolbar) findViewById(R.id.search_toolbar);
    ViewCompat.setElevation(toolbar, ViewUnit.getElevation(this, 2));

    String keyWord = getIntent().getStringExtra(getString(R.string.search_intent_key_word));
    if (keyWord == null) {
        keyWord = getString(R.string.search_defauft_key_word);
    }

    setActionBar(toolbar);
    getActionBar().setTitle(keyWord);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    searchFragment = (SearchFragment) getSupportFragmentManager().findFragmentById(R.id.search_fragment);
}
 
Example #4
Source File: InReplyToActivity.java    From Tweetin with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ViewUnit.setCustomTheme(this);
    setContentView(R.layout.in_reply_to);

    Toolbar toolbar = (Toolbar) findViewById(R.id.in_reply_to_toolbar);
    ViewCompat.setElevation(toolbar, ViewUnit.getElevation(this, 2));

    setActionBar(toolbar);
    getActionBar().setTitle(getString(R.string.in_reply_to_label));
    getActionBar().setDisplayHomeAsUpEnabled(true);

    inReplyToFragment = (InReplyToFragment) getSupportFragmentManager().findFragmentById(R.id.in_reply_to_fragment);
}
 
Example #5
Source File: DetailActivity.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_detail);

    postponeEnterTransition();

    TransitionSet transitions = new TransitionSet();
    Slide slide = new Slide(Gravity.BOTTOM);
    slide.setInterpolator(AnimationUtils.loadInterpolator(this,
            android.R.interpolator.linear_out_slow_in));
    slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    transitions.addTransition(slide);
    transitions.addTransition(new Fade());
    getWindow().setEnterTransition(transitions);

    Intent intent = getIntent();
    sharedElementCallback = new DetailSharedElementEnterCallback(intent);
    setEnterSharedElementCallback(sharedElementCallback);
    initialItem = intent.getIntExtra(IntentUtil.SELECTED_ITEM_POSITION, 0);
    setUpViewPager(intent.<Photo>getParcelableArrayListExtra(IntentUtil.PHOTO));

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(navigationOnClickListener);

    super.onCreate(savedInstanceState);
}
 
Example #6
Source File: Main.java    From isu with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FragmentActivityWeakReference = new WeakReference < FragmentActivity > (this);

    setContentView(R.layout.main);
    String cmiyc = Tools.readString("cmiyc", null, this);
    if (cmiyc == null || cmiyc.isEmpty())
        Tools.saveString("cmiyc", Tools.random4(), this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setActionBar(toolbar);

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(new TabsPagerAdapter(getFragmentManager()));
    viewPager.setOffscreenPageLimit(getTitles().length);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.setupWithViewPager(viewPager);

    mMasked = (TextView) findViewById(R.id.masked);

    if (!Tools.appId(getApplicationContext()))
        mMasked.setText(getString(R.string.masked));

    mAbout = (TextView) findViewById(R.id.about);
    mAbout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(getApplicationContext(), AboutActivity.class);
            startActivity(myIntent);
        }
    });
    check_writeexternalstorage();
}
 
Example #7
Source File: MenuBindingAdapter.java    From deagle with Apache License 2.0 5 votes vote down vote up
@BindingAdapter("menu") public static void inflateMenu(final Toolbar toolbar, final @MenuRes int old_menu, final @MenuRes int new_menu) {
	if (SDK_INT < LOLLIPOP) return;
	if (new_menu == old_menu) return;
	final Menu menu = toolbar.getMenu();
	menu.clear();
	toolbar.inflateMenu(new_menu);
}
 
Example #8
Source File: RssfeedActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Toolbar tb = (Toolbar) findViewById(R.id.toolbar);
    tb.inflateMenu(R.menu.mainmenu);
    tb.setOnMenuItemClickListener(
            new Toolbar.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    return onOptionsItemSelected(item);
                }
            });
    return true;
}
 
Example #9
Source File: RssfeedActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar tb = (Toolbar) findViewById(R.id.toolbar);
        setActionBar(tb);

        if (getResources().getBoolean(R.bool.twoPaneMode)) {
// all good, we use the fragments defined in the layout
            return;
        }
// if savedInstanceState is null we do some cleanup
        if (savedInstanceState != null) {
// cleanup any existing fragments in case we are in detailed mode ①
            getFragmentManager().executePendingTransactions();
            Fragment fragmentById = getFragmentManager().
                    findFragmentById(R.id.fragment_container);
            if (fragmentById != null) {
                getFragmentManager().beginTransaction()
                        .remove(fragmentById).commit();
            }
        }
        MyListFragment listFragment = new MyListFragment();
        getFragmentManager().beginTransaction()
                .replace(R.id.fragment_container, listFragment).commit();


    }
 
Example #10
Source File: MainActivity.java    From android-DirectShare with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    setActionBar((Toolbar) findViewById(R.id.toolbar));
    mEditBody = (EditText) findViewById(R.id.body);
    findViewById(R.id.share).setOnClickListener(mOnClickListener);
}
 
Example #11
Source File: UserGuide.java    From island with Apache License 2.0 5 votes vote down vote up
private static View findProperTarget(final View view) {
	if (! (view instanceof Toolbar)) return view;
	final ViewGroup group = (ViewGroup) view;
	for (int i = 0; i < group.getChildCount(); i ++) {
		final View child = group.getChildAt(i);
		if (child instanceof ActionMenuView) return ((ActionMenuView) child).getChildAt(0);	// ActionMenuItemView
	}
	return view;
}
 
Example #12
Source File: SplashActivityTest.java    From ThinkMap with Apache License 2.0 4 votes vote down vote up
public static Matcher<View> navigationIconMatcher() {
    return allOf(
            isAssignableFrom(ImageButton.class),
            withParent(isAssignableFrom(Toolbar.class)));
}
 
Example #13
Source File: AvatarImageBehavior.java    From CollapsingToolbar-With-Webview with Apache License 2.0 4 votes vote down vote up
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, CircleImageView child, View dependency) {
    return dependency instanceof Toolbar;
}
 
Example #14
Source File: DetailActivity.java    From android-instant-apps with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_detail);

    postponeEnterTransition();

    TransitionSet transitions = new TransitionSet();
    Slide slide = new Slide(Gravity.BOTTOM);
    slide.setInterpolator(AnimationUtils.loadInterpolator(this,
            android.R.interpolator.linear_out_slow_in));
    slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    transitions.addTransition(slide);
    transitions.addTransition(new Fade());
    getWindow().setEnterTransition(transitions);

    Intent intent = getIntent();
    sharedElementCallback = new DetailSharedElementEnterCallback(intent);
    setEnterSharedElementCallback(sharedElementCallback);
    try {
        initialItem = Integer.parseInt(intent.getData().getLastPathSegment());
    } catch (NumberFormatException e) {
        initialItem = 0;
    }
    PhotoService.getInstance().getPhotosAsync(new PhotoService.PhotoCallback() {
        @Override
        public void success(ArrayList<Photo> photos) {
            setUpViewPager(photos);
            findViewById(android.R.id.empty).setVisibility(View.GONE);
        }

        @Override
        public void error() {
            finishAfterTransition();
        }
    });

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(navigationOnClickListener);

    super.onCreate(savedInstanceState);
}
 
Example #15
Source File: DetailActivity.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_detail);

    postponeEnterTransition();

    TransitionSet transitions = new TransitionSet();
    Slide slide = new Slide(Gravity.BOTTOM);
    slide.setInterpolator(AnimationUtils.loadInterpolator(this,
            android.R.interpolator.linear_out_slow_in));
    slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    transitions.addTransition(slide);
    transitions.addTransition(new Fade());
    getWindow().setEnterTransition(transitions);

    Intent intent = getIntent();
    sharedElementCallback = new DetailSharedElementEnterCallback(intent);
    setEnterSharedElementCallback(sharedElementCallback);
    try {
        initialItem = Integer.parseInt(intent.getData().getLastPathSegment());
    } catch (NumberFormatException e) {
        initialItem = 0;
    }
    PhotoService.getInstance().getPhotosAsync(new PhotoService.PhotoCallback() {
        @Override
        public void success(ArrayList<Photo> photos) {
            setUpViewPager(photos);
            findViewById(android.R.id.empty).setVisibility(View.GONE);
        }

        @Override
        public void error() {
            finishAfterTransition();
        }
    });

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(navigationOnClickListener);

    super.onCreate(savedInstanceState);
}
 
Example #16
Source File: TitleTextColorSetter.java    From aircon with MIT License 4 votes vote down vote up
@Override
protected Class<Toolbar> getViewClass() {
	return Toolbar.class;
}
 
Example #17
Source File: TitleTextColorSetter.java    From aircon with MIT License 4 votes vote down vote up
@Override
protected void setAttr(final Toolbar view, final int color) {
	view.setTitleTextColor(color);
}