Android 带有 DialogFragment 的相机
Android Camera with DialogFragment
我正在尝试构建一个 DialogFragment,它允许一个人带走人并删除他们。我已经打开里面的相机拍照了
但是,我需要将每个拇指都设置为左边的方块。而第一个去大方块,点击拇指时,显示在大方块上。
有人可以帮助我吗?下面是代码:
public class FotosFragment extends DialogFragment {
private static final int CAMERA_REQUEST = 1888;
Uri fileUri = null;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog_fotos_fragment, container);
ImageView picture01 = (ImageView) view.findViewById(R.id.picture01);
ImageView picture02 = (ImageView) view.findViewById(R.id.picture02);
ImageView picture03 = (ImageView) view.findViewById(R.id.picture03);
getDialog().setTitle("DialogFragment Tutorial");
picture01.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
picture02.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
picture03.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
return view;
}
}
这是布局示例:
据我了解你的问题。捕获图片后,您想在大框中显示图片吗?为此,您需要为 picture01、picture02 和 picture03 设置一些标志,如果照片已经拍摄,那么您当然希望在大盒子内显示。现在你需要这样的东西
boolean isPictue01isTaken = false;
picture01.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(isPictue01isTaken){
// show image 01 in big box here. if bigbox is your imageview then set image bitmap that you already captured,
}else {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
isPictue01isTake = true;
}
}
});
我正在尝试构建一个 DialogFragment,它允许一个人带走人并删除他们。我已经打开里面的相机拍照了
但是,我需要将每个拇指都设置为左边的方块。而第一个去大方块,点击拇指时,显示在大方块上。
有人可以帮助我吗?下面是代码:
public class FotosFragment extends DialogFragment {
private static final int CAMERA_REQUEST = 1888;
Uri fileUri = null;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog_fotos_fragment, container);
ImageView picture01 = (ImageView) view.findViewById(R.id.picture01);
ImageView picture02 = (ImageView) view.findViewById(R.id.picture02);
ImageView picture03 = (ImageView) view.findViewById(R.id.picture03);
getDialog().setTitle("DialogFragment Tutorial");
picture01.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
picture02.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
picture03.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
return view;
}
}
这是布局示例:
据我了解你的问题。捕获图片后,您想在大框中显示图片吗?为此,您需要为 picture01、picture02 和 picture03 设置一些标志,如果照片已经拍摄,那么您当然希望在大盒子内显示。现在你需要这样的东西
boolean isPictue01isTaken = false;
picture01.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(isPictue01isTaken){
// show image 01 in big box here. if bigbox is your imageview then set image bitmap that you already captured,
}else {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
isPictue01isTake = true;
}
}
});