Giter VIP home page Giter VIP logo

Comments (10)

amaroukun17 avatar amaroukun17 commented on July 29, 2024 1

hi i just want to ask how can i make view for each navigation item ?
thanks in advance. i'm new to android programming

from materialintroview.

bkodirov avatar bkodirov commented on July 29, 2024

How can I select certain menu item?

from materialintroview.

iammert avatar iammert commented on July 29, 2024

@OneManStudioDotSe I will add this to sample asap. But you can achieve by following snippet.

private View getDrawerView(Toolbar toolbar) {
        for (int i = 0; i < toolbar.getChildCount(); i++) {
            if (toolbar.getChildAt(i) instanceof ImageButton)
                return toolbar.getChildAt(i);
        }
        return null;
    }

Give toolbar as a parameter.

from materialintroview.

danpetre avatar danpetre commented on July 29, 2024

Toolbar has 2 ImageButton (mNavButtonView,mCollapseButtonView)

try with reflection

Field field = Toolbar.class.getDeclaredField("mNavButtonView");
field.setAccessible(true);
view = (ImageButton)field.get(toolbar);

from materialintroview.

DJafari avatar DJafari commented on July 29, 2024

i'm using this function to get humberger view of toolbar :

public static View getToolbarNavigationIcon(Toolbar toolbar){
        boolean hadContentDescription = TextUtils.isEmpty(toolbar.getNavigationContentDescription());
        String contentDescription = !hadContentDescription ? toolbar.getNavigationContentDescription().toString() : "navigationIcon";
        toolbar.setNavigationContentDescription(contentDescription);
        ArrayList<View> potentialViews = new ArrayList<>();
        toolbar.findViewsWithText(potentialViews,contentDescription, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
        View navIcon = null;
        if(potentialViews.size() > 0){
            navIcon = potentialViews.get(0);
        }
        if(hadContentDescription)
            toolbar.setNavigationContentDescription(null);
        return navIcon;
    }

from materialintroview.

DJafari avatar DJafari commented on July 29, 2024

@Behzodbek just find view by menu item id, sample in activity :

View favoriteItemView = findViewById(R.id.fav);

my menu xml file :

<?xml version="1.0" encoding="utf-8"?>
<menu
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item 
        android:title="Fav It!" 
        android:id="@+id/fav" 
        app:showAsAction="always" />
</menu>

from materialintroview.

iammert avatar iammert commented on July 29, 2024

@DJafari actually your code seems like doing same thing with mine. You get index 0 if list is not empty, I get first imagebutton on childlist.

from materialintroview.

iammert avatar iammert commented on July 29, 2024

@Behzodbek If your problem is not solved please create new issue. Because seems like this drawer issue is solved.

from materialintroview.

nextflex avatar nextflex commented on July 29, 2024

Is there any way to focus the ActionBarDrawerToggle at the new ActionBar?

from materialintroview.

riki-dexter avatar riki-dexter commented on July 29, 2024

@DJafari

just find view by menu item id, sample in activity :

It's not working for me. Can you explain more?

from materialintroview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.