我想为此目的添加文本视图和按钮,如何在不创建新布局文件的情况下执行此操作?目的是录制视频,可能使用一个按钮,然后该按钮将向用户提问,用户在视频中回答该问题。这有可能吗?如果没有,我将尝试进行新的布局,但是,在后端,我还将获取视频路径的结果并上传到aws服务。有什么建议吗?请查看评论。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.changeQuestion).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String n = String.valueOf(next());
textViewQuestions.setVisibility(View.VISIBLE);
textViewQuestions.setText(n);
}
});
}
public void captureVideo(View view) {
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
//Uri fileUri=Uri.fromFile(new File(dir,"sample_video.mp4"));
Uri fileUri = Uri.fromFile(fileToUpload);
videoIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
videoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
videoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 360);
//videoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 5491520L); // 5MB size limit
videoIntent.putExtra(MediaStore.Video.Thumbnails.HEIGHT, height/2);
videoIntent.putExtra(MediaStore.Video.Thumbnails.WIDTH, width;
//videoIntent.putExtra(TextView.AUTOFILL_HINT_NAME, "Questions");
//videoIntent.putExtra(TextView. // set height
//videoIntent.putExtra(TextView. // set width
//videoIntent.putExtra(TextView. // set x
//videoIntent.putExtra(TextView. // set y constraints?
//videoIntent.putExtra(Button. make new button
//videoIntent.putExtra(Button. use button changeQuestion
//videoIntent.PutExtra(Button. set height/width/x/y
startActivityForResult(videoIntent, VIDEO_REQUEST_CODE);
//startActivity(new Intent(getApplicationContext(), VideoActivity.class));
}