Java Code Examples for android.widget.Toolbar

The following examples show how to use android.widget.Toolbar. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: animation-samples   Source File: DetailActivity.java    License: 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 2
Source Project: Tweetin   Source File: InReplyToActivity.java    License: 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 3
Source Project: Tweetin   Source File: SearchActivity.java    License: 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 Project: Tweetin   Source File: PictureActivity.java    License: 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 5
Source Project: MonsterHunter4UDatabase   Source File: GenericActivity.java    License: 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 6
Source Project: island   Source File: UserGuide.java    License: 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 7
Source Project: isu   Source File: Main.java    License: 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 8
Source Project: android-DirectShare   Source File: MainActivity.java    License: 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 9
@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
@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 11
Source Project: deagle   Source File: MenuBindingAdapter.java    License: 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 12
Source Project: aircon   Source File: TitleTextColorSetter.java    License: MIT License 4 votes vote down vote up
@Override
protected void setAttr(final Toolbar view, final int color) {
	view.setTitleTextColor(color);
}
 
Example 13
Source Project: aircon   Source File: TitleTextColorSetter.java    License: MIT License 4 votes vote down vote up
@Override
protected Class<Toolbar> getViewClass() {
	return Toolbar.class;
}
 
Example 14
Source Project: atlas   Source File: DetailActivity.java    License: 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 Project: android-instant-apps   Source File: DetailActivity.java    License: 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
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, CircleImageView child, View dependency) {
    return dependency instanceof Toolbar;
}
 
Example 17
Source Project: ThinkMap   Source File: SplashActivityTest.java    License: Apache License 2.0 4 votes vote down vote up
public static Matcher<View> navigationIconMatcher() {
    return allOf(
            isAssignableFrom(ImageButton.class),
            withParent(isAssignableFrom(Toolbar.class)));
}