Search in sources :

Example 1 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    drawer = (ListView) findViewById(R.id.drawer);
    drawer.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    String[] rows = getResources().getStringArray(R.array.drawer_rows);
    drawer.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_row, rows));
    drawer.setOnItemClickListener(this);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    toggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);
    drawerLayout.setDrawerListener(toggle);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    getFragmentManager().addOnBackStackChangedListener(this);
    if (getFragmentManager().findFragmentById(R.id.content) == null) {
        showLorem();
    }
}
Also used : ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle)

Example 2 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project cheesesquare by chrisbanes.

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);
    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Here's a Snackbar", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : NavigationView(android.support.design.widget.NavigationView) TabLayout(android.support.design.widget.TabLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) ViewPager(android.support.v4.view.ViewPager) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) AdapterView(android.widget.AdapterView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 3 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project Android-PanesLibrary by cricklet.

the class PhoneDelegate method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    if (findViewById(R.id.content_frame) == null)
        setContentView(R.layout.phone_layout);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    drawerToggle = new ActionBarDrawerToggle(getActivity(), drawer, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {

        public void onDrawerClosed(View view) {
            supportInvalidateOptionsMenu();
        // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            supportInvalidateOptionsMenu();
        // creates call to onPrepareOptionsMenu()
        }
    };
    drawer.setDrawerListener(drawerToggle);
    FragmentManager fm = getSupportFragmentManager();
    fm.addOnBackStackChangedListener(this);
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) View(android.view.View)

Example 4 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project AnimeTaste by daimajia.

the class StartActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mContext = this;
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
    mVideoList = (ListView) findViewById(R.id.videoList);
    mDrawerList = (ListView) findViewById(R.id.function_list);
    mDrawer = (LinearLayout) findViewById(R.id.drawer);
    mLayoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mCategoryList = (ListView) findViewById(R.id.category_list);
    mFooterView = mLayoutInflater.inflate(R.layout.load_item, null);
    mLoadProgress = (ProgressBar) mFooterView.findViewById(R.id.loading);
    mLoadText = (TextView) mFooterView.findViewById(R.id.load_text);
    mVideoList.addFooterView(mFooterView);
    mVideoList.setOnScrollListener(this);
    mDrawer.setOnTouchListener(this);
    View headerView = mLayoutInflater.inflate(R.layout.gallery_item, null, false);
    mVideoList.addHeaderView(headerView);
    mRecommendPager = (ViewPager) headerView.findViewById(R.id.pager);
    mRecommendPager.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            PointF downP = new PointF();
            PointF curP = new PointF();
            int act = event.getAction();
            if (act == MotionEvent.ACTION_DOWN || act == MotionEvent.ACTION_MOVE || act == MotionEvent.ACTION_UP) {
                ((ViewGroup) v).requestDisallowInterceptTouchEvent(true);
                if (downP.x == curP.x && downP.y == curP.y) {
                    return false;
                }
            }
            return false;
        }
    });
    mRecommendIndicator = (UnderlinePageIndicator) headerView.findViewById(R.id.indicator);
    if (getIntent().hasExtra("Success")) {
        init(getIntent());
    } else {
        Toast.makeText(mContext, R.string.init_failed, Toast.LENGTH_SHORT).show();
        finish();
    }
    mDrawerAapter = new SimpleAdapter(this, getDrawerItems(), R.layout.drawer_item, new String[] { "img", "title" }, new int[] { R.id.item_icon, R.id.item_name });
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_action_navigation_menu, R.string.app_name, R.string.app_name) {

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (mPreviousType != mType || mPreviousCategoryId != mCategoryId) {
                mCurrentPage = 1;
                mIsEnd = false;
                mVideoAdapter.removeAllData();
                mFooterView.findViewById(R.id.loading).setVisibility(View.VISIBLE);
                mFooterView.findViewById(R.id.load_text).setVisibility(View.INVISIBLE);
                triggerApiConnector();
            }
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            mPreviousType = mType;
            mPreviousCategoryId = mCategoryId;
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerList.setAdapter(mDrawerAapter);
    mDrawerList.setOnItemClickListener(this);
    ViewUtils.setListViewHeightBasedOnChildren(mDrawerList);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayUseLogoEnabled(true);
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
    getSupportActionBar().setLogo(R.drawable.rsz_ab_icon);
    rateForUsOrCheckUpdate();
    showWhatsNew();
}
Also used : OnTouchListener(android.view.View.OnTouchListener) PointF(android.graphics.PointF) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) SimpleAdapter(android.widget.SimpleAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) MotionEvent(android.view.MotionEvent)

Example 5 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (getFragmentManager().findFragmentById(R.id.content) == null) {
        showLorem();
    }
    ListView drawer = (ListView) findViewById(R.id.drawer);
    drawer.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_row, getResources().getStringArray(R.array.drawer_rows)));
    drawer.setOnItemClickListener(this);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    toggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);
    drawerLayout.setDrawerListener(toggle);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
}
Also used : ListView(android.widget.ListView) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle)

Aggregations

View (android.view.View)54 DrawerLayout (android.support.v4.widget.DrawerLayout)51 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)33 AdapterView (android.widget.AdapterView)22 ListView (android.widget.ListView)21 NavigationView (android.support.design.widget.NavigationView)18 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)17 Intent (android.content.Intent)16 Toolbar (android.support.v7.widget.Toolbar)16 TextView (android.widget.TextView)14 ImageView (android.widget.ImageView)10 ActionBar (android.support.v7.app.ActionBar)9 SharedPreferences (android.content.SharedPreferences)8 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 ViewPager (android.support.v4.view.ViewPager)6 ArrayList (java.util.ArrayList)5 SuppressLint (android.annotation.SuppressLint)4 ActionBar (android.app.ActionBar)4 TypedArray (android.content.res.TypedArray)4 Paint (android.graphics.Paint)4