Merge "Don't ignore explicit dividerHeight of 0 specified in XML" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9be801c826
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.widget;
|
package android.widget;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
@@ -144,7 +145,7 @@ public class ListView extends AbsListView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ListView(Context context, AttributeSet attrs) {
|
public ListView(Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, com.android.internal.R.attr.listViewStyle);
|
this(context, attrs, R.attr.listViewStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListView(Context context, AttributeSet attrs, int defStyleAttr) {
|
public ListView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
@@ -155,38 +156,37 @@ public class ListView extends AbsListView {
|
|||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
|
||||||
final TypedArray a = context.obtainStyledAttributes(
|
final TypedArray a = context.obtainStyledAttributes(
|
||||||
attrs, com.android.internal.R.styleable.ListView, defStyleAttr, defStyleRes);
|
attrs, R.styleable.ListView, defStyleAttr, defStyleRes);
|
||||||
|
|
||||||
CharSequence[] entries = a.getTextArray(
|
final CharSequence[] entries = a.getTextArray(R.styleable.ListView_entries);
|
||||||
com.android.internal.R.styleable.ListView_entries);
|
|
||||||
if (entries != null) {
|
if (entries != null) {
|
||||||
setAdapter(new ArrayAdapter<CharSequence>(context,
|
setAdapter(new ArrayAdapter<>(context, R.layout.simple_list_item_1, entries));
|
||||||
com.android.internal.R.layout.simple_list_item_1, entries));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Drawable d = a.getDrawable(com.android.internal.R.styleable.ListView_divider);
|
final Drawable d = a.getDrawable(R.styleable.ListView_divider);
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
// If a divider is specified use its intrinsic height for divider height
|
// Use an implicit divider height which may be explicitly
|
||||||
|
// overridden by android:dividerHeight further down.
|
||||||
setDivider(d);
|
setDivider(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Drawable osHeader = a.getDrawable(
|
final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
|
||||||
com.android.internal.R.styleable.ListView_overScrollHeader);
|
|
||||||
if (osHeader != null) {
|
if (osHeader != null) {
|
||||||
setOverscrollHeader(osHeader);
|
setOverscrollHeader(osHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Drawable osFooter = a.getDrawable(
|
final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
|
||||||
com.android.internal.R.styleable.ListView_overScrollFooter);
|
|
||||||
if (osFooter != null) {
|
if (osFooter != null) {
|
||||||
setOverscrollFooter(osFooter);
|
setOverscrollFooter(osFooter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the height specified, zero being the default
|
// Use an explicit divider height, if specified.
|
||||||
final int dividerHeight = a.getDimensionPixelSize(
|
if (a.hasValueOrEmpty(R.styleable.ListView_dividerHeight)) {
|
||||||
com.android.internal.R.styleable.ListView_dividerHeight, 0);
|
final int dividerHeight = a.getDimensionPixelSize(
|
||||||
if (dividerHeight != 0) {
|
R.styleable.ListView_dividerHeight, 0);
|
||||||
setDividerHeight(dividerHeight);
|
if (dividerHeight != 0) {
|
||||||
|
setDividerHeight(dividerHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
|
mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
|
||||||
@@ -3434,18 +3434,23 @@ public class ListView extends AbsListView {
|
|||||||
* Returns the drawable that will be drawn between each item in the list.
|
* Returns the drawable that will be drawn between each item in the list.
|
||||||
*
|
*
|
||||||
* @return the current drawable drawn between list elements
|
* @return the current drawable drawn between list elements
|
||||||
|
* @attr ref R.styleable#ListView_divider
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Drawable getDivider() {
|
public Drawable getDivider() {
|
||||||
return mDivider;
|
return mDivider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the drawable that will be drawn between each item in the list. If the drawable does
|
* Sets the drawable that will be drawn between each item in the list.
|
||||||
* not have an intrinsic height, you should also call {@link #setDividerHeight(int)}
|
* <p>
|
||||||
|
* <strong>Note:</strong> If the drawable does not have an intrinsic
|
||||||
|
* height, you should also call {@link #setDividerHeight(int)}.
|
||||||
*
|
*
|
||||||
* @param divider The drawable to use.
|
* @param divider the drawable to use
|
||||||
|
* @attr ref R.styleable#ListView_divider
|
||||||
*/
|
*/
|
||||||
public void setDivider(Drawable divider) {
|
public void setDivider(@Nullable Drawable divider) {
|
||||||
if (divider != null) {
|
if (divider != null) {
|
||||||
mDividerHeight = divider.getIntrinsicHeight();
|
mDividerHeight = divider.getIntrinsicHeight();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user