一键Android的多个动作 [英] Android multiple actions for one Button

查看:97
本文介绍了一键Android的多个动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天的家伙!我真的serioulsy停留在编程我的Andr​​oid application.This的问题球员。 我的应用程序,它使用与表面View.I了只有一个按钮,通过理念应该访问摄像头后,然后访问它的拍照摄像头广播。 我想,如果和else语句,但并没有帮助我,我搜索整个互联网没有人能够给出什么好的解决办法。 因此,通过观念,只有按钮,在一个活动要做好这两个功能:打开摄像头,开启拍摄后。 请帮助我,在此先感谢。

Good Day guys! I am really serioulsy stuck on programming my android application.This is the problem guys. I have application which uses camera broadcasting with surface View.I got only one button which by idea should make access to a camera then after accessing it take a picture. I tried if and else statements but didn't help me.I searched whole internet nobody can give any good solution. So by idea that only one button in one activity should do these two functions:Open camera,after opening capture. Please help me and thanks in advance.

推荐答案

您还可以使用布尔跟踪摄像状态(打开或关闭)。然后根据布尔值,你可以调用两种不同的方法。像:mCameraOpen是布尔

You can also use boolean to keep track of camera state(open or close). Then depending upon the boolean value you can call two different methods. Like : mCameraOpen is boolean

`@Override
public void onClick(View v){
  if (mCameraOpen){
     methodToCaptureImage();
  }else{
     mCameraOpen = true;
     methodToOpenCamera();
  }
}`

这篇关于一键Android的多个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆