由于相机图像存储在imageview中,因此应用程序性能变慢。
有时申请失败。怎么解决?
public void onClick(View v) {
if(v.getId() == camerabutton.getId()){
addImageView();
}
}
private void addImageView(){
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(MediaStore.Images.Media.CONTENT_TYPE);
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, REQ_CODE_SELECT_IMAGE);
}
@Override
protected void onActivityResult(int requestCode , int resultCode , Intent data) {
if(requestCode == 100){
if(resultCode == Activity.RESULT_OK){
ImageView imageView = new ImageView(this);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(postArea.getWidth(), ViewGroup.LayoutParams.WRAP_CONTENT);
imageView.setLayoutParams(params);
//params.width = postArea.getWidth();
imageView.setLayoutParams(params);
Uri imgUri = data.getData();
imageView.setImageURI(imgUri);
postArea.addView(imageView);
}
}
}
}
postArea是LinenerLayout~这段代码是将imageView添加到Layout
答案 0 :(得分:1)
将uri转换为位图并将位图缩放到所需大小或imageview的大小。这也将减少位图的大小以及用于加载它的内存。尝试类似下面的内容
$query= $this->db->select('*')->from('sales')->where('branch',$_SESSION['branch'])->where('date_sold >=',$from)->where('date_sold <=',$to)->get();
您还可以压缩位图以减小尺寸。