0
工作如何與VideoView
和Fragments
如何使用VideoView和片段
public class Tab2 extends Fragment implements View.OnClickListener {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.tab2, container, false);
Button play = (Button)rootView.findViewById(R.id.play);
VideoView vid = (VideoView) rootView.findViewById(R.id.videoView);
return rootView;
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.play:
String videopath = "android.resource://" + getPackageName() + "/" + R.raw.prod;
Uri uri = Uri.parse(videopath);
vid.setVideoURI(uri);
vid.start();
}
}
}
什麼是你有錯誤或問題? –