Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android PagerTitlestrip不';我没有画出第一个标题_Android - Fatal编程技术网

Android PagerTitlestrip不';我没有画出第一个标题

Android PagerTitlestrip不';我没有画出第一个标题,android,Android,我正在尝试向一个ViewPager添加两个装饰。一个是PageIndicator,是我定制的装饰,另一个是标准的PagerTitleStrip 将它们作为ViewPager的子项添加到XML中没有任何作用,至少PageIndicator的构造函数甚至没有被调用。因此,我目前正在使用以下代码: mPageIndicator = new PageIndicator(this); PagerTitleStrip strip=new PagerTitleStrip(this); float d=get

我正在尝试向一个ViewPager添加两个装饰。一个是PageIndicator,是我定制的装饰,另一个是标准的PagerTitleStrip

将它们作为ViewPager的子项添加到XML中没有任何作用,至少PageIndicator的构造函数甚至没有被调用。因此,我目前正在使用以下代码:

mPageIndicator = new PageIndicator(this);
PagerTitleStrip strip=new PagerTitleStrip(this);

float d=getResources().getDisplayMetrics().density;

ViewPager.LayoutParams params = new ViewPager.LayoutParams();
params.isDecor = true;
params.gravity = Gravity.BOTTOM;
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
mPageIndicator.setLayoutParams(params);

ViewPager.LayoutParams params2=new ViewPager.LayoutParams();
params2.isDecor = true;
params2.gravity = Gravity.BOTTOM;
params2.height= (int) (20*d);
strip.setLayoutParams(params2);

mViewPager.addView(strip);
mViewPager.addView(mPageIndicator);
这将在活动的onStart期间执行,因为我正在显示具有相同活动的初始屏幕,并在onStart中调用setContentView

这使得两个装饰在视图的底部都可见,但是在浏览视图一次之前,标题栏不会显示任何文本,而向后浏览会显示第一页的标题。每当调用mViewPager的setAdapter时,此行为就会重复。设置适配器时,我尝试调用setCurrentItem两次,但似乎没有帮助


如何解决这个问题?

正如Commonware指出的,这是appcompat-v4 23.0.1的一个错误。我通过返回支持appcompat-v7和appcompat-v4版本22.2.0解决了这个问题


重复问题提供了一种替代解决方案。

正如Commonware指出的,这是appcompat-v4 23.0.1的一个错误。我通过返回支持appcompat-v7和appcompat-v4版本22.2.0解决了这个问题

重复的问题提供了另一种解决方案。

也许你遇到了。也许你遇到了。