How to set up custom delimited ListView using Android?

I wanted to implement the Pull to Refresh function in my Android application, so I implemented this library: Android-PullToRefresh . However, I cannot show that the user style shares programmatically.

The code is simple:

list = (PullToRefreshListView) findViewById(R.id.list);
int[] colors = {0, 0xFF97CF4D, 0}; 
list.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
list.setDividerHeight(1);

However, this causes this error: The method setDivider(GradientDrawable) is undefined for the type PullToRefreshListViewandThe method setDividerHeight(int) is undefined for the type PullToRefreshListView.

What am I doing wrong here?

+5
source share
1 answer

PullToRefreshListViewis not ListView, therefore, this error. You must access the ListViewinside PullToRefreshListViewand call methods on it 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);

XML ,

:

<com.handmark.pulltorefresh.library.PullToRefreshListView
  android:divider="@drawable/fancy_gradient"
  android:dividerHeight="@dimen/divider_height"...
+8

All Articles