How can I change my custom toolbar icon dynamically

前端 未结 2 1849
一个人的身影
一个人的身影 2021-01-29 09:57

In my application I\'m using toolbar which having imageview in it. I need to change that imageview dynamically .

Here is my toolbar.xm

2条回答
  •  轮回少年
    2021-01-29 10:25

    Try this

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    
    toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.back_arrow));
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    

提交回复
热议问题