我有片段视频观看。当我按下按钮时,它在横向模式下显示为全视图,但是当我按下它时应该进入正常视图。为此,我在Activity中处理onBackPressed()
但我无法在Activity
中获取该视频观看的ID。那么如何在Activity
onBackPressed()
Fragment
类Fragment
中获取视频观看ID。
这是fullScreen = (ImageView) controller.findViewById(R.id.fullscreen);
fullScreen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 8.0f);
videoView.setLayoutParams(param);
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
});
中以完整视图显示视频的代码:
Activity
这是我需要在@Override
public void onBackPressed() {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 5.0f);
videoView.setLayoutParams(param);
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
super.onBackPressed();
}
}
:
videoView
但我需要Activity
个ID。如何在<select id='selectdesign'>
<option value="0"></option>
<option value="top">top</option>
<option value="jeans">jeans</option>
</select>
<select id='selectmenu'>
<option value="0"></option>
<option value="1">top-blue</option>
<option value="2">top-pink</option>
<option value="3">bottoms-red</option>
<option value="4">bottoms-violet</option>
</select>
function selectOption(element) {
if (element.value == 'top') {
console.log('if');
option[2].setAttribute('selected', true);
} else if (element.value == 'jeans') {
console.log('else if');
option[1].setAttribute('selected', true);
}
}
中获取它?
答案 0 :(得分:1)
强力方式是从你的片段中获取该视图:
@Override
public void onBackPressed() {
VideoView videoView = yourFragment.getView().findViewById(R.id.your_video_view);
...
}
答案 1 :(得分:0)
您可以执行以下操作之一: