WEB开发网
开发学院手机开发Android 开发 android listView 子控件事件错行处理 阅读

android listView 子控件事件错行处理

 2012-11-16 15:34:01 来源:WEB开发网   
核心提示:catch(IOException e){String log = "打印时间:" + Communal.getInstance().getFormatDate("") + "ApplincationActivity异常:" + e.getMessage();
catch(IOException e)
{
String log = "打印时间:" + Communal.getInstance().getFormatDate("") + "ApplincationActivity异常:" + e.getMessage();
LogFile.getInstance().addLog(log);
e.printStackTrace();
}
catch (Exception e) {

String log = "打印时间:" + Communal.getInstance().getFormatDate("") + "ApplincationActivity异常:" + e.getMessage();
LogFile.getInstance().addLog(log);
e.printStackTrace();
}

return null;
}

/***************************************************************************/
public Bitmap getBitmapFromFile(File dst, int width, int height) {
if (null != dst && dst.exists()) {
BitmapFactory.Options opts = null;
if (width > 0 && height > 0) {
opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(dst.getPath(), opts);
// 计算图片缩放比例
final int minSideLength = Math.min(width, height);
opts.inSampleSize = computeSampleSize(opts, minSideLength,
width * height);
opts.inJustDecodeBounds = false;
opts.inInputShareable = true;
opts.inPurgeable = true;
}
try {
return BitmapFactory.decodeFile(dst.getPath(), opts);
} catch (OutOfMemoryError e) {
String log = "打印时间:" + Communal.getInstance().getFormatDate("") + "ApplincationActivity异常:" + e.getMessage();
LogFile.getInstance().addLog(log);
e.printStackTrace();
}
}
return null;
}

public static int computeSampleSize(BitmapFactory.Options options,
int minSideLength, int maxNumOfPixels) {
int initialSize = computeInitialSampleSize(options, minSideLength,
maxNumOfPixels);


int roundedSize;
if (initialSize <= 8) {
roundedSize = 1;
while (roundedSize < initialSize) {
roundedSize <<= 1;
}
} else {
roundedSize = (initialSize + 7) / 8 * 8;
}


return roundedSize;
}


private static int computeInitialSampleSize(BitmapFactory.Options options,
int minSideLength, int maxNumOfPixels) {
double w = options.outWidth;
double h = options.outHeight;


int lowerBound = (maxNumOfPixels == -1) ? 1 : (int) Math.ceil(Math
.sqrt(w * h / maxNumOfPixels));
int upperBound = (minSideLength == -1) ? 128 : (int) Math.min(Math
.floor(w / minSideLength), Math.floor(h / minSideLength));


if (upperBound < lowerBound) {
// return the larger one when there is no overlapping zone.
return lowerBound;
}


if ((maxNumOfPixels == -1) && (minSideLength == -1)) {
return 1;
} else if (minSideLength == -1) {
return lowerBound;
} else {
return upperBound;
}
}

private void setSpinnerValue(String[] str,Spinner spinner,String spinnerTitle)
{
//准备一个数组适配器
ArrayAdapter adapter = new ArrayAdapter<String>(context,android.R.layout.simple_spinner_item,str);
//设置下拉样式
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//为下拉列表设置适配器
spinner.setAdapter(adapter);
spinner.setPrompt(spinnerTitle);
}


}

上一页  5 6 7 8 9 10 

Tags:android listView 控件

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接