Java Code Examples for android.support.v4.widget.DrawerLayout#findViewById()

The following examples show how to use android.support.v4.widget.DrawerLayout#findViewById() . 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: AttendanceActivity.java    From bunk with MIT License 6 votes vote down vote up
private void setupDrawer() {
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    Toolbar toolbar = findViewById(R.id.toolbar);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    View navigationViewHeader = navigationView.getHeaderView(0);
    ((TextView) navigationViewHeader.findViewById(R.id.name)).setText(this.newStudent.name);
    ((TextView) navigationViewHeader.findViewById(R.id.username)).setText(this.newStudent.username);
    String prompts[] = {"open source?", "coding?", "programming?", "code+coffee?"};
    TextView opensource = drawer.findViewById(R.id.opensource);
    opensource.setText(prompts[new Random().nextInt(prompts.length)]);
    TextView github = drawer.findViewById(R.id.github);
    github.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
    github.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.github_url))));
        }
    });
}
 
Example 2
Source File: MenuControl.java    From AndroidTranslucentUI with Apache License 2.0 6 votes vote down vote up
public void initMenu() {
	menuLayout = (DrawerLayout) fa.findViewById(R.id.menu_layout);
	menuElementsList = (ListView) fa.findViewById(R.id.menu_elements);
	// ������Ӱ
	menuLayout.setDrawerShadow(R.drawable.drawer_shadow,GravityCompat.START);
	myApp = (MyApplication)fa.getApplication();
	
	menuItemList = new ArrayList<MenuItemBean>();
	menuItemList = MenuBaseUtils.arrayToList(fa);
	slideMenuAdapter = new SlideMenuAdapter(menuItemList,menuLayout,fa);
	menuElementsList.setAdapter(slideMenuAdapter);
	menuElementsList.setOnItemClickListener(this);
	setCurrentFragment(0);
	//���ò໬�˵����
	menuContentLayout = (LinearLayout)menuLayout.findViewById(R.id.menu_content_layout);
	menuContentLayout.getLayoutParams().width = MenuBaseUtils.getScreenPixels(fa).getScreenWidth()*2/3;
	
	exitLayout = (LinearLayout)menuLayout.findViewById(R.id.exit_layout);
	exitLayout.setOnClickListener(this);
	profileLayout = (LinearLayout)menuLayout.findViewById(R.id.profile_layout);
	profileLayout.setOnClickListener(this);
}
 
Example 3
Source File: DrawerHeader.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
public DrawerHeader(MainActivity activity, DrawerLayout drawerLayout) {
    this.activity = activity;
    headerLayout = drawerLayout.findViewById(R.id.drawer_header_container);
    avatar = (ImageView) headerLayout.findViewById(R.id.drawer_header_avatar);
    nick = (TextView) headerLayout.findViewById(R.id.drawer_header_nick);
    openLinkButton = (ImageButton) headerLayout.findViewById(R.id.drawer_header_open_link);
    openLinkButton.setOnClickListener(v -> {
        activity.getDrawers().closeMenu();
        activity.getDrawers().closeTabs();
        String url;
        url = Utils.readFromClipboard();
        if (url == null) url = "";
        final FrameLayout frameLayout = new FrameLayout(activity);
        frameLayout.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        frameLayout.setPadding(App.px24, 0, App.px24, 0);
        final EditText linkField = new EditText(activity);
        frameLayout.addView(linkField);
        linkField.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        linkField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
        linkField.setText(url);
        new AlertDialog.Builder(activity)
                .setTitle(R.string.follow_link)
                .setView(frameLayout)
                .setPositiveButton(R.string.follow, (dialog, which) -> IntentHandler.handle(linkField.getText().toString()))
                .setNegativeButton(R.string.cancel, null)
                .show();
    });
    ClientHelper.get().addLoginObserver(loginObserver);
    Client.get().addNetworkObserver(networkObserver);
    state(ClientHelper.getAuthState() == ClientHelper.AUTH_STATE_LOGIN);
}
 
Example 4
Source File: BlurSupport.java    From EtsyBlur with Apache License 2.0 5 votes vote down vote up
public static void addTo(@NonNull final DrawerLayout drawerLayout) {
    View viewToBlur = drawerLayout.getChildAt(0);
    final View blurringView = drawerLayout.findViewById(R.id.blurring_view);

    if (viewToBlur == null) {
        throw new IllegalStateException("There's no view to blur. DrawerLayout does not have the first child view.");
    }

    if (blurringView == null) {
        throw new IllegalStateException("There's no blurringView. Include BlurringView with id set to 'blurring_view'");
    }

    if (!(blurringView instanceof BlurringView)) {
        throw new IllegalStateException("blurring_view must be type BlurringView");
    }

    ((BlurringView) blurringView).blurredView(viewToBlur);

    drawerLayout.addDrawerListener(new BlurDrawerListener((BlurringView) blurringView));

    drawerLayout.post(new Runnable() {
        @Override
        public void run() {
            if (drawerLayout.isDrawerVisible(GravityCompat.START) || drawerLayout.isDrawerVisible(GravityCompat.END)) {
                // makes sure to set it to be visible if the drawer is visible at start
                blurringView.setVisibility(View.VISIBLE);
            }
        }
    });
}
 
Example 5
Source File: BaseActivity.java    From EasyVPN-Free with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setContentView(int layoutResID)
{
    if (BuildConfig.FLAVOR == "pro" || BuildConfig.FLAVOR == "underground") {
        availableFilterAds = true;
        premiumServers = true;
    }

    fullLayout = (DrawerLayout) getLayoutInflater().inflate(R.layout.activity_base, null);
    FrameLayout activityContainer = (FrameLayout) fullLayout.findViewById(R.id.activity_content);
    getLayoutInflater().inflate(layoutResID, activityContainer, true);
    super.setContentView(fullLayout);

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

    if (useToolbar()) {
        setSupportActionBar(toolbar);
    } else {
        toolbar.setVisibility(View.GONE);
    }

    if (useHomeButton()) {
        if (getSupportActionBar() != null){
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
        }
    }

    if (BuildConfig.DEBUG) {
        moreServersSKU = TEST_ITEM_SKU;
        adblockSKU = TEST_ITEM_SKU;
    } else {
        moreServersSKU = MORE_SERVERS_ITEM_SKU;
        adblockSKU = ADBLOCK_ITEM_SKU;
    }



    dbHelper = new DBHelper(this);

    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);

    widthWindow = dm.widthPixels;
    heightWindow = dm.heightPixels;

    localeCountries = CountriesNames.getCountries();

    App application = (App) getApplication();
    mTracker = application.getDefaultTracker();
}
 
Example 6
Source File: NavDrawer.java    From smartcard-reader with GNU General Public License v3.0 4 votes vote down vote up
public NavDrawer(Activity activity, Bundle inState,
                 int resId, DrawerLayout drawerLayout, Toolbar toolbar) {
    mActivity = activity;
    mResId = resId;
    mDrawerLayout = drawerLayout;

    // this only takes effect on Lollipop, or when using translucentStatusBar on Kitkat
    drawerLayout.setStatusBarBackgroundColor(activity.getResources().getColor(R.color.primary));
    mParentItem = drawerLayout.findViewById(resId);
    mParentItem.setActivated(true);

    mDrawerToggle = new ActionBarDrawerToggle(activity, drawerLayout,
            toolbar, R.string.app_name, R.string.app_name) {

        /** called when a drawer has settled in a completely closed state */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            // force call to onPrepareOptionsMenu()
            mActivity.invalidateOptionsMenu();
        }

        /** called when a drawer has settled in a completely open state */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // force call to onPrepareOptionsMenu()
            mActivity.invalidateOptionsMenu();
        }
    };
    drawerLayout.setDrawerListener(mDrawerToggle);

    View appSelect = drawerLayout.findViewById(R.id.app_select);
    View batchSelect = drawerLayout.findViewById(R.id.batch_select);
    View emvRead = drawerLayout.findViewById(R.id.emv_read);
    View apps = drawerLayout.findViewById(R.id.apps);
    View settings = drawerLayout.findViewById(R.id.settings);

    appSelect.setOnClickListener(mClickListener);
    batchSelect.setOnClickListener(mClickListener);
    emvRead.setOnClickListener(mClickListener);
    apps.setOnClickListener(mClickListener);
    settings.setOnClickListener(mClickListener);

    if (inState != null) {
        if (inState.getBoolean("drawer_open")) {
            drawerLayout.openDrawer(Gravity.START|Gravity.LEFT);
        }
    }
}