Android:setIndicatorBounds在果冻豆或更高版本中
我创建了一个带有Android:setIndicatorBounds在果冻豆或更高版本中,android,api,expandablelistview,Android,Api,Expandablelistview,我创建了一个带有自定义可扩展列表视图的应用程序。它很好用。但我在Jelly BeansetIndicatorBounds中读到了这一点。我的工作对象是: 中文版本:14 目标版本:18 我尝试过这个,但它给了我一个错误: 调用需要API级别18(当前最小值为14):android.widget.ExpandableListView#setIndicatorBoundsRelative DisplayMetrics metrics = new DisplayMetrics();
自定义可扩展列表视图的应用程序。它很好用。但我在Jelly BeansetIndicatorBounds
中读到了这一点。我的工作对象是:
- 中文版本:14
- 目标版本:18
我尝试过这个,但它给了我一个错误:
调用需要API级别18(当前最小值为14):android.widget.ExpandableListView#setIndicatorBoundsRelative
DisplayMetrics metrics = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
int anchoPantalla = metrics.widthPixels;
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
expListView.setIndicatorBounds(anchoPantalla - GetDipsFromPixel(40),
anchoPantalla - GetDipsFromPixel(10));
} else {
expListView.setIndicatorBoundsRelative(anchoPantalla - GetDipsFromPixel(40),
anchoPantalla - GetDipsFromPixel(10));
}
DisplayMetrics=新的DisplayMetrics();
((活动)上下文).getWindowManager().getDefaultDisplay().getMetrics(度量);
int anchopantala=metrics.widthPixels;
if(android.os.Build.VERSION.SDK\u INT
如何从Jelly Bean修复错误并使代码正常工作?谢谢。。。
...
DisplayMetrics metrics = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
int anchoPantalla = metrics.widthPixels;
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
expListView.setIndicatorBounds(anchoPantalla - GetDipsFromPixel(40),
anchoPantalla - GetDipsFromPixel(10));
} else {
JB_setIndicatorBoundsRelative(anchoPantalla - GetDipsFromPixel(40),
anchoPantalla - GetDipsFromPixel(10));
}
}
...
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void JB_setIndicatorBoundsRelative(int left, int right)
{
expListView.setIndicatorBoundsRelative(left, right);
}
DisplayMetrics=新的DisplayMetrics();
((活动)上下文).getWindowManager().getDefaultDisplay().getMetrics(度量);
int anchopantala=metrics.widthPixels;
if(android.os.Build.VERSION.SDK\u INT
我也有同样的问题,请有人指导我们吗?