Tho*_*mer 14
您需要创建一个扩展ListView的新类.
package com.mypackage;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
public class ColorFadeListView extends ListView
{
// fade to green by default
private static int mFadeColor = 0xFF00FF00;
public ColorFadeListView(Context context, AttributeSet attrs)
{
this(context, attrs,0);
}
public ColorFadeListView(Context context, AttributeSet attrs, int defStyle)
{
super(context,attrs,defStyle);
setFadingEdgeLength(30);
setVerticalFadingEdgeEnabled(true);
}
@Override
public int getSolidColor()
{
return mFadeColor;
}
public void setFadeColor( int fadeColor )
{
mFadeColor = fadeColor;
}
public int getFadeColor()
{
return mFadeColor;
}
}
Run Code Online (Sandbox Code Playgroud)
您可以将此列表视图与法线相同地使用ListView(尽管您必须正确地使用fadeColor访问器方法).在XML中,而不是定义对象作为<ListView android:properties.../>定义<com.mypackage.ColorFadeListView android:properties.../>
| 归档时间: |
|
| 查看次数: |
6776 次 |
| 最近记录: |