Search in sources :

Example 46 with Toolbar

use of android.support.v7.widget.Toolbar in project cardslib by gabrielemariotti.

the class DemoSingleTopicActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.carddemo_activity_singletopic);
    final Toolbar toolbar = getActionBarToolbar();
    toolbar.setNavigationIcon(R.drawable.ic_up21);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            finish();
        }
    });
    final String customTitle = getIntent().getStringExtra(Intent.EXTRA_TITLE);
    mHandler.post(new Runnable() {

        @Override
        public void run() {
            if (getIntent().hasExtra(Intent.EXTRA_TITLE)) {
                toolbar.setTitle(getIntent().getStringExtra(Intent.EXTRA_TITLE));
            }
            toolbar.setTitle(customTitle != null ? customTitle : getTitle());
        //toolbar.setTitle("");
        }
    });
    if (savedInstanceState == null) {
        mFragment = getFragmentFromIntent();
        mFragment.setArguments(intentToFragmentArguments(getIntent()));
        getFragmentManager().beginTransaction().replace(R.id.container, mFragment, "single_pane").commit();
    } else {
        mFragment = (BaseFragment) getFragmentManager().findFragmentByTag("single_pane");
    }
}
Also used : View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 47 with Toolbar

use of android.support.v7.widget.Toolbar in project fresco by facebook.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    if (savedInstanceState == null) {
        int selectedItem = PreferenceManager.getDefaultSharedPreferences(this).getInt(KEY_SELECTED_NAVDRAWER_ITEM_ID, INITIAL_NAVDRAWER_ITEM_ID);
        handleNavigationItemClick(selectedItem);
        navigationView.setCheckedItem(selectedItem);
    }
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 48 with Toolbar

use of android.support.v7.widget.Toolbar in project android-seed by freezy.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (toolbar != null) {
        toolbar.setTitle(R.string.app_name);
        setSupportActionBar(toolbar);
    }
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
    }
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) View(android.view.View)

Example 49 with Toolbar

use of android.support.v7.widget.Toolbar in project MaterialViewPager by florent37.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTitle("");
    ButterKnife.bind(this);
    final Toolbar toolbar = mViewPager.getToolbar();
    if (toolbar != null) {
        setSupportActionBar(toolbar);
    }
    mViewPager.getViewPager().setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            switch(position % 4) {
                //    return WebViewFragment.newInstance();
                default:
                    return RecyclerViewFragment.newInstance();
            }
        }

        @Override
        public int getCount() {
            return 4;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch(position % 4) {
                case 0:
                    return "Selection";
                case 1:
                    return "Actualités";
                case 2:
                    return "Professionnel";
                case 3:
                    return "Divertissement";
            }
            return "";
        }
    });
    mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {

        @Override
        public HeaderDesign getHeaderDesign(int page) {
            switch(page) {
                case 0:
                    return HeaderDesign.fromColorResAndUrl(R.color.green, "http://phandroid.s3.amazonaws.com/wp-content/uploads/2014/06/android_google_moutain_google_now_1920x1080_wallpaper_Wallpaper-HD_2560x1600_www.paperhi.com_-640x400.jpg");
                case 1:
                    return HeaderDesign.fromColorResAndUrl(R.color.blue, "http://www.hdiphonewallpapers.us/phone-wallpapers/540x960-1/540x960-mobile-wallpapers-hd-2218x5ox3.jpg");
                case 2:
                    return HeaderDesign.fromColorResAndUrl(R.color.cyan, "http://www.droid-life.com/wp-content/uploads/2014/10/lollipop-wallpapers10.jpg");
                case 3:
                    return HeaderDesign.fromColorResAndUrl(R.color.red, "http://www.tothemobile.com/wp-content/uploads/2014/07/original.jpg");
            }
            return null;
        }
    });
    mViewPager.getViewPager().setOffscreenPageLimit(mViewPager.getViewPager().getAdapter().getCount());
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
    final View logo = findViewById(R.id.logo_white);
    if (logo != null) {
        logo.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mViewPager.notifyHeaderChanged();
                Toast.makeText(getApplicationContext(), "Yes, the title is clickable", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
Also used : FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter) MaterialViewPager(com.github.florent37.materialviewpager.MaterialViewPager) HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign) Fragment(android.support.v4.app.Fragment) RecyclerViewFragment(com.github.florent37.materialviewpager.sample.fragment.RecyclerViewFragment) BindView(butterknife.BindView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 50 with Toolbar

use of android.support.v7.widget.Toolbar in project agera by google.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_act);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
}
Also used : Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Toolbar (android.support.v7.widget.Toolbar)496 View (android.view.View)358 ActionBar (android.support.v7.app.ActionBar)178 TextView (android.widget.TextView)167 RecyclerView (android.support.v7.widget.RecyclerView)134 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)123 ImageView (android.widget.ImageView)84 Intent (android.content.Intent)75 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)56 ArrayList (java.util.ArrayList)56 BindView (butterknife.BindView)46 AppCompatActivity (android.support.v7.app.AppCompatActivity)41 AdapterView (android.widget.AdapterView)41 NavigationView (android.support.design.widget.NavigationView)39 BarPainter (com.xabber.android.ui.color.BarPainter)36 MenuItem (android.view.MenuItem)35 FloatingActionButton (android.support.design.widget.FloatingActionButton)31 ViewPager (android.support.v4.view.ViewPager)31 ViewGroup (android.view.ViewGroup)31 Bundle (android.os.Bundle)29