我有一个 android 项目,所有源代码都没有错误,但有时它会强制关闭。
这是我的代码:
时间完成对话框.java
public class TimeCompleteDialog implements OnClickListener {
private Activity act;
private LayoutInflater inflater;
/**UI Components*/
private Dialog dialog;
private TextView txt_msg;
private ImageButton btn_cancal;
public TimeCompleteDialog(Activity a) {
this.act=a;
inflater=LayoutInflater.from(act);
dialog=new Dialog(a);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
/**Attaching the dialog to custom views*/
private void buildDialog(){
View v=inflater.inflate(R.layout.time_complete_dialog,null,false);
dialog.setContentView(v);
dialog.setCancelable(false);
this.findDialogViews(v);
}
public void showDialog(){
this.buildDialog();
this.dialog.show();
}
/**Find the ids of the custom views components*/
private void findDialogViews(View view){
txt_msg=(TextView)view.findViewById(R.id.txt_time_up);
btn_cancal=(ImageButton)view.findViewById(R.id.btn_time_cancel);
btn_cancal.setOnClickListener(this);
/**Changing the state of …Run Code Online (Sandbox Code Playgroud) android ×1