DropDownMenu的默认选中无效

xiaoxiao2025-08-31  7

compile 'com.github.dongjunkun:DropDownMenu:1.0.4'

项目引用该框架的,在默认选中控件无效,下可以在自定义一个控件  extends DropDownMenu,然后在里面添加一个方法

public void setpos(int current_tab_position){ this.current_tab_position=current_tab_position; }

为什么这么写主要,是我们setTabText(text)的源码是:

 

public void setTabText(String text) { if(this.current_tab_position != -1) { ((TextView)this.tabMenuView.getChildAt(this.current_tab_position)).setText(text); } }

不拿控件去监听无法传入current_tab_position值,它会默认-1,就不执行下去,所以要那个控件改变值需要传值。

 

 

至于第二个  mDropDownMenu.setpos(2);设置   2  因为我要改变的控件是父类的第三个孩子。

你是这么选择的,如图:

 

 

 

 

那么滑动到别的页面,你再回来还是这个值和这些数据。

转载请注明原文地址: https://www.6miu.com/read-5035502.html

最新回复(0)