您的位置:首页 > 移动开发 > Android开发

Android onClick

2015-10-29 15:47 337 查看
在layout中直接声明onclick方法:

<Button
android:id="@+id/button_capture"
android:layout_width = "fill_parent"
android:layout_height="wrap_content"
android:layout_gravity = "bottom"
android:onClick = "onCaptureClick"
android:text="@string/btnCapture"/>


此处方法作用域必须是public,否则会出错

public void onCaptureClick(View v) {
// TODO Auto-generated method stub
if(isRecording) {
mRecorder.stop();
releaseMediaRecorder();

mCamera.lock();

setButtonCaptureText("Capture");
isRecording = false;
releaseCamera();
} else {
new MediaPrepareTask().execute(null, null, null);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: