本文为原创,转载请说明出处,谢谢~
界面比较简单,就是弹出一个自定义的对话框,对话框中自动播放视频,播放完毕后对话框消失,跟一些视频广告比较相似。
自定义对话框代码,其中重写了findViewById函数和写了getDialogView函数来获取dialog中的自定义控件
public class VideoPlayDialog extends Dialog {
Context context;
private View dialogView;
public VideoPlayDialog(Context context) {
super(context);
this.context = context;
}
public VideoPlayDialog(Context context, int theme){
super(context, theme);
this.context = context;
LayoutInflater inflater= LayoutInflater.from(context);
dialogView = inflater.inflate(R.layout.videoplaydialog, null);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(dialogView);
}
@Override
public View findViewById(int id) {
//重写findView