@Override
public void drawableStateChanged() {
Drawable background = getBackground();
if(background != null) {
if(!isEnabled()) {
background.setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
} else {
background.setColorFilter(null);
}
}
}
引用来的没有亲测 备用吧
FileOutputStream fos = openFileOutput("urls.txt", Context.MODE_PRIVATE);
fos.write("Alex".getBytes());
fos.close();
FileInputStream fis = openFileInput("urls.txt");
int c;
while((c=fis.read())!=-1)
{
k += (char)c;
}
fis.close();
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
listView 有时候项目太少占用空间太大,如何能够自动控制
自适用大小
package com.customcontrols;
public class NoScrollListView extends ListView
{
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, 0) );
// here I assume that height's being calculated for one-child only, seen it in ListView's source which is actually a bad idea
int childHeight = getMeasuredHeight() - (getListPaddingTop() + getListPaddingBottom() + getVerticalFadingEdgeLength() * 2);
int fullHeight = getListPaddingTop() + getListPaddingBottom() + childHeight*(getCount());
setMeasuredDimension(getMeasuredWidth(), fullHeight);
}
}