直播平臺原始碼,Android中常用Dialog彈窗效果

zhibo系統開發發表於2022-06-14

直播平臺原始碼,Android中常用Dialog彈窗效果

1、ProgressDialog

    private  void showProgressDialog(){
        progressDialog = new ProgressDialog(DialogDemo.this);
        //設定提示資訊
        progressDialog.setTitle("提示");
        progressDialog.setIcon(R.mipmap.touxiang0);
        progressDialog.setMessage("正在處理中");
        //是否用過返回鍵取消
        progressDialog.setCancelable(true);
        //碰觸彈框之外的地方取消
        progressDialog.setCanceledOnTouchOutside(true);
        //顯示
        progressDialog.show();
    }


2、DatePickerDialog

 //日期
    private  void datePickerDialog(){
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
            DatePickerDialog datePickerDialog = new DatePickerDialog(DialogDemo.this);
            datePickerDialog.setOnDateSetListener(new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                    Toast.makeText(DialogDemo.this,year+"年"+(month+1)+"月"+dayOfMonth+"日",Toast.LENGTH_SHORT).show();
                }
            });
            datePickerDialog.show();
        }else {
            Toast.makeText(DialogDemo.this,"版本過低",Toast.LENGTH_SHORT).show();
        }
    }


3、TimePickerDialog

    //時間
    private  void timePickerDialog(){
        //獲得日曆的實列
        Calendar calendar = Calendar.getInstance();
        //設定當前時間
        calendar.setTimeInMillis(System.currentTimeMillis());
        //獲取時分
        int hour  = calendar.get(Calendar.HOUR_OF_DAY);
        int minute = calendar.get(Calendar.MINUTE);
        //第三、四個引數初始時分 第五個引數是否為24小時顯示
        TimePickerDialog time = new TimePickerDialog(DialogDemo.this, new TimePickerDialog.OnTimeSetListener() {
            @Override
            public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                Toast.makeText(DialogDemo.this,"Hour"+hourOfDay+"minute"+minute,Toast.LENGTH_SHORT).show();
            }
        },hour,minute,true);
        time.show();
    }


以上就是直播平臺原始碼,Android中常用Dialog彈窗效果, 更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2900457/,如需轉載,請註明出處,否則將追究法律責任。

相關文章