当前位置: 首页>>代码示例>>Java>>正文


Java NavigationView.setItemIconTintList方法代码示例

本文整理汇总了Java中android.support.design.widget.NavigationView.setItemIconTintList方法的典型用法代码示例。如果您正苦于以下问题:Java NavigationView.setItemIconTintList方法的具体用法?Java NavigationView.setItemIconTintList怎么用?Java NavigationView.setItemIconTintList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.design.widget.NavigationView的用法示例。


在下文中一共展示了NavigationView.setItemIconTintList方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setSideBarDrawer

import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
private void setSideBarDrawer( DrawerLayout mDrawer, NavigationView navView,
                               Toolbar toolbar, DBHelper helper) {
    // enables toggle button on toolbar to open the sidebar
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, mDrawer, toolbar, R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    mDrawer.addDrawerListener(toggle);
    toggle.syncState();

    // set up side navigation bar layout
    navView.setNavigationItemSelectedListener(this);

    // Want to display icons in original color scheme
    navView.setItemIconTintList(null);

    // highlight the current location
    navView.setCheckedItem(R.id.nav_matches);

    // sets up TextViews in sidebar to display the user's name and email
    sidebarUserName = (android.widget.TextView) navView.getHeaderView(0)
            .findViewById(R.id.sidebar_username);
    sidebarUserEmail = navView.getHeaderView(0)
            .findViewById(R.id.sidebar_user_email);
    setSideBarText( sidebarUserName, sidebarUserEmail, helper );
}
 
开发者ID:chrisqz95,项目名称:couch-potatoes,代码行数:26,代码来源:MatchingActivity.java

示例2: setSideBarDrawer

import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
private void setSideBarDrawer( DrawerLayout mDrawer, NavigationView navView,
                               Toolbar toolbar, DBHelper helper) {
    // enables toggle button on toolbar to open the sidebar
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, mDrawer, toolbar, R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    mDrawer.addDrawerListener(toggle);
    toggle.syncState();

    // set up side navigation bar layout
    navView.setNavigationItemSelectedListener(this);

    // Want to display icons in original color scheme
    navView.setItemIconTintList(null);

    // highlight the current location
    navView.setCheckedItem(R.id.nav_matches);

    // sets up TextViews in sidebar to display the user's name and email
    sidebarUserName = (android.widget.TextView) navView.getHeaderView(0)
            .findViewById(R.id.sidebar_username);
    sidebarUserEmail = (android.widget.TextView) navView.getHeaderView(0)
            .findViewById(R.id.sidebar_user_email);
    setSideBarText( sidebarUserName, sidebarUserEmail, helper );
}
 
开发者ID:chrisqz95,项目名称:couch-potatoes,代码行数:26,代码来源:ProfileActivity.java

示例3: onCreate

import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    // Incializa elementos
    this.mViewHolder.mFloatAddGuest = (FloatingActionButton) this.findViewById(R.id.float_add_guest);

    // Toolbar - Menu superior
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Menu Drawer que contém as opções que trazem as fragments
    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();

    // Seta os eventos de click para o menu Drawer
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setItemIconTintList(null);

    // Inicia eventos de click
    this.setListeners();

    // Incia default fragment
    this.startDefaultFragment();
}
 
开发者ID:DevMasterTeam,项目名称:GerenciadorDeConvidados,代码行数:32,代码来源:MainActivity.java

示例4: onCreate

import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    actionBar = getSupportActionBar();
    actionBar.setHomeAsUpIndicator(R.drawable.ic_rest);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(R.string.app_name);


    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setItemIconTintList(null);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setCheckedItem(R.id.nav_rest);


    mViewPager = (AdvancedViewPager) findViewById(R.id.pager);
    PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(pagerAdapter);

    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setTitle(navigationView.getMenu().getItem(position).getTitle());
            actionBar.setHomeAsUpIndicator(R.drawable.ic_rest);
            navigationView.getMenu().getItem(position).setChecked(true);
            invalidateOptionsMenu();
        }
    });

}
 
开发者ID:Sayi,项目名称:RestClient,代码行数:37,代码来源:HomeActivity.java

示例5: initNavigationView

import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
private void initNavigationView() {
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this,
            drawer, mToolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView mNavigationView = findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);
    mNavigationView.setItemIconTintList(null);
    mNavigationView.setCheckedItem(R.id.nav_home);
}
 
开发者ID:Shuanghua,项目名称:LikeGank,代码行数:14,代码来源:MainActivity.java

示例6: setupNavView

import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
private void setupNavView() {
    toolbar = (Toolbar) findViewById(R.id.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);
    navigationView.setItemIconTintList(null);

    View header = navigationView.getHeaderView(0);
    nav_headerTextView = (TextView) header.findViewById(R.id.nav_headerTextView);
}
 
开发者ID:CommonsLab,项目名称:CommonsLab,代码行数:16,代码来源:MainActivity.java

示例7: onCreate

import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
/**
 * ATTENTION: This was auto-generated to implement the App Indexing API.
 * See https://g.co/AppIndexing/AndroidStudio for more information.
 */

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_select);

    ll_select_content = (LinearLayout) findViewById(R.id.ll_select_content);
    mBuyHomeViewHolder = new BuyHomeViewHolder(ll_select_content);
    mBuyHomeViewHolder.init();
    removeOtherView();
    ll_select_content.addView(mBuyHomeViewHolder.getView());

    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) findViewById(R.id.nav_view);
    navigationView.setItemIconTintList(null);
    navigationView.setNavigationItemSelectedListener(this);

    Intent intent = getIntent();
    final String username = intent.getStringExtra("username");
    tv0 = (TextView) navigationView.getHeaderView(0).findViewById(R.id.textView0);
    tv0.setText(username);

    //String path = "http://172.16.64.203:8080/数据库查询/SelectHome";
    String path = RestConstants.API_HOST + "数据库查询/SelectHome";
    //String path = "http://192.168.43.191:8080/数据库查询/SelectHome";
    //String path = "http://172.16.88.222:8080/数据库查询/RegiStration";
    Map<String, String> params = new HashMap<>();
    params.put("1", "1");
    OkHttpManager.getInstance().post(path, params, new OnHttpCallback() {
        @Override
        public void onSuccess(String str) {
            String s[] = str.split("%");
            String ss[] = s[0].split("#");
            String sa[][] = new String[ss.length][];
            for(int i=0;i<ss.length;i++){
                sa[i] = ss[i].split("@");
            }
            //int i = 0;
            List<Home> list = new ArrayList<Home>();
            for (int i=0;i<sa.length;i++){
                for (int j=0;j<sa[i].length;j+=17) {
                    System.out.println(sa[i][j]+"++++"+sa[i][j+16]);
                    Home home = new Home(username,sa[i][j],sa[i][j+16]);
                    list.add(home);
                }
            }

            mBuyHomeViewHolder.notifySetDataChanged(list);

            if("读取成功".equals(s[1])){
                Toast.makeText(SelectActivity.this,s[1], Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void onError(Throwable e) {
            e.printStackTrace();
            Toast.makeText(SelectActivity.this, "读取失败,请重新读取!", Toast.LENGTH_LONG).show();
        }
    });
}
 
开发者ID:wzy75,项目名称:Real-estate-agent-management-system,代码行数:74,代码来源:SelectActivity.java

示例8: process

import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
@Override
    public void process(@NonNull Context context, @Nullable String key, @Nullable NavigationView view, @Nullable Void extra) {
        if (view == null || !Config.navigationViewThemed(context, key))
            return;

        boolean darkTheme = false;
        if (view.getBackground() != null && view.getBackground() instanceof ColorDrawable) {
            final ColorDrawable cd = (ColorDrawable) view.getBackground();
            darkTheme = !ATEUtil.isColorLight(cd.getColor());
        }

        final ColorStateList iconSl = new ColorStateList(
                new int[][]{
                        new int[]{-android.R.attr.state_checked},
                        new int[]{android.R.attr.state_checked}
                },
                new int[]{
                        Config.navigationViewNormalIcon(context, key, darkTheme),
                        Config.navigationViewSelectedIcon(context, key, darkTheme)
                });
        final ColorStateList textSl = new ColorStateList(
                new int[][]{
                        new int[]{-android.R.attr.state_checked},
                        new int[]{android.R.attr.state_checked}
                },
                new int[]{
                        Config.navigationViewNormalText(context, key, darkTheme),
                        Config.navigationViewSelectedText(context, key, darkTheme)
                });
        view.setItemTextColor(textSl);
        view.setItemIconTintList(iconSl);

        StateListDrawable bgDrawable = new StateListDrawable();
        bgDrawable.addState(new int[]{android.R.attr.state_checked}, new ColorDrawable(
                Config.navigationViewSelectedBg(context, key, darkTheme)));
        view.setItemBackground(bgDrawable);

        // TODO not needed since the layout inflater will catch it?
//        final View headerView = view.getHeaderView(0);
//        if (headerView != null) ATE.themeView(context, headerView, key);
    }
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:42,代码来源:NavigationViewProcessor.java

示例9: setupDrawerLayout

import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
/**
 * Initialize the drawer and apply a custom color for every item.
 */
private void setupDrawerLayout() {
    drawerLayout = findViewById(R.id.drawer_layout);
    NavigationView navigationView = findViewById(R.id.navigation_view);
    navigationView.setItemIconTintList(null);
    navigationView.setNavigationItemSelectedListener(this);
    View header = navigationView.getHeaderView(0);
    header.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, LoginActivity.class));
            drawerLayout.closeDrawers();
        }
    });

    final Toolbar toolbar = findViewById(R.id.toolbar);
    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(
            this,  drawerLayout, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close
    );
    drawerLayout.addDrawerListener(actionBarDrawerToggle);
    actionBarDrawerToggle.syncState();

    Drawable icon;
    if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
        icon = getDrawable(R.drawable.circle);
    } else {
        icon = getResources().getDrawable(R.drawable.circle);
    }
    Menu menu = navigationView.getMenu();
    if (getIntent().getExtras() == null) {
        menu.getItem(1).setChecked(true);
    } else {
        int index = getIntent().getExtras().getInt(Constants.EXTRA_INDEX_CATEGORY, 1);
        menu.getItem(index).setChecked(true);
    }
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        int colorId = colorCats.get(item.getItemId());
        if (colorId > 0 && icon != null) {
            // Item must be "cloned" in order to apply a new color, otherwise we're just updating the same object reference
            Drawable.ConstantState constantState = icon.getConstantState();
            if (constantState != null) {
                Drawable clone = constantState.newDrawable();
                int color = ContextCompat.getColor(getBaseContext(), colorId);
                if (colorId == R.color.cat_color_news && ThemeUtils.isDarkTheme(getBaseContext())) {
                    color = ContextCompat.getColor(getBaseContext(), R.color.cat_color_news_dark);
                }
                clone.setColorFilter(color, PorterDuff.Mode.SRC);
                item.setIcon(clone);
            }
        }
    }
}
 
开发者ID:MBach,项目名称:LeMondeRssReader,代码行数:57,代码来源:MainActivity.java

示例10: onCreate

import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation);

    // START Google sign in API client
    // configure sign-in to request user info
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestIdToken(Constants.SERVER_CLIENT_ID)
            .requestServerAuthCode(Constants.SERVER_CLIENT_ID)
            .build();

    // build client with access to Google Sign-In API and the options specified by gso
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    // END Google sign in API client

    // START prepare main layout
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mProgressBar = findViewById(R.id.progressBar);

    mSwipeRefreshLayout = findViewById(R.id.swipe_container);
    mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.colorAccent));
    mSwipeRefreshLayout.setRefreshing(true);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            updateAndDisplayRegisteredKeys();
        }
    });

    mRecyclerView = findViewById(R.id.list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new SecurityTokenAdapter(new ArrayList<Map<String, String>>(),
            R.layout.row_token, U2FDemoActivity.this);
    // END prepare main layout

    // START prepare drawer layout
    DrawerLayout drawer = 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 = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setItemIconTintList(null);
    View header = navigationView.getHeaderView(0);
    mUserEmailTextView = header.findViewById(R.id.userEmail);
    mDisplayNameTextView = header.findViewById(R.id.displayName);
    Menu menu = navigationView.getMenu();
    mU2fOperationMenuItem = menu.findItem(R.id.nav_u2fOperations);
    mSignInMenuItem = menu.findItem(R.id.nav_signin);
    mSignOutMenuItem = menu.findItem(R.id.nav_signout);
    mSignInButton = findViewById(R.id.sign_in_button);
    mSignInButton.setSize(SignInButton.SIZE_WIDE);
    mSignInButton.setScopes(gso.getScopeArray());
    mSignInButton.setOnClickListener(this);
    // END prepare drawer layout

    // request SignIn or load registered tokens
    updateUI();
}
 
开发者ID:googlesamples,项目名称:android-fido,代码行数:71,代码来源:U2FDemoActivity.java


注:本文中的android.support.design.widget.NavigationView.setItemIconTintList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。