inp*_*put 5 android listview pull-to-refresh
我想在我的android应用程序中实现Pull to Refresh功能,所以我实现了这个库:Android-PullToRefresh.但是,我似乎无法设置自定义样式以编程方式划分.
代码很简单:
list = (PullToRefreshListView) findViewById(R.id.list);
int[] colors = {0, 0xFF97CF4D, 0};
list.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
list.setDividerHeight(1);
Run Code Online (Sandbox Code Playgroud)
但是,它抛出了这个错误:The method setDivider(GradientDrawable) is undefined for the type PullToRefreshListView和The method setDividerHeight(int) is undefined for the type PullToRefreshListView.
我在这做错了什么?
PullToRefreshListView不是ListView,因此错误.你应该访问ListView内部PullToRefreshListView并调用setDivider*方法.
list = (PullToRefreshListView) findViewById(R.id.list);
int[] colors = {0, 0xFF97CF4D, 0};
ListView inner = list.getRefreshableView();
inner.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
inner.setDividerHeight(1);
Run Code Online (Sandbox Code Playgroud)
作为替代,你可以定义渐变为一个XML绘制,并在布局权设定的属性,如显示的示例中这里
例如:
<com.handmark.pulltorefresh.library.PullToRefreshListView
android:divider="@drawable/fancy_gradient"
android:dividerHeight="@dimen/divider_height"...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3053 次 |
| 最近记录: |