Tuesday 28 April 2020

Different Types Of Android Dialog




Different Types Of Android Dialog
Android Dialog
Alert Dialog                                  Download: Code
AlertDialog.Builder builder = new AlertDialog.Builder(this);//this is activity
    builder.setMessage(R.string.show_alert)
            .setPositiveButton(R.string.show, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    show_alert.setText("Alert Showed");
                }
            }).setNegativeButton(R.string.dont, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            show_alert.setText("Alert Not Showed");
        }
    }).show();
 
Custom Dialog
    TextView title = new TextView(this);
    title.setText(R.string.Custom_alert);
    title.setTextColor(R.color.title);
    title.setPadding(20, 20, 20, 20);
    title.setGravity(Gravity.CENTER);
    title.setBackgroundColor(R.color.white);
    title.setTextSize(20);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);//this is activity
    builder.setMessage(R.string.show_alert)
            .setCustomTitle(title)
            .setPositiveButton(R.string.show, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    show_alert.setText("Alert Showed");
                }
            }).setNegativeButton(R.string.dont, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            show_alert.setText("Alert Not Showed");
        }
    }).show();

Source Code - Download

Saturday 25 April 2020

Get Audio Duration from URL in HTML

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title> Get Duration</title>
  </head>
  <body>
    <h1>Get Duration of Audio file from URL in HTML</h1>
    <audio id="audio-element">
  <source src="http://labs.qnimate.com/files/mp3.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>
<br>
<button onclick="duration();">Get Duration</button>
<p id="demo"></p>
<script type="text/javascript">
  function duration()
{
    var audio = document.getElementById("audio-element");
    if(audio.readyState > 0) 
    {
        var minutes = parseInt(audio.duration / 60, 10);
        var seconds = parseInt(audio.duration % 60);
        document.getElementById("demo").innerHTML="Duration - "+minutes+":"+seconds;
    }
}
</script>
  </body>
</html>
                                                  Download: Code

Output - 



Source Code - Download 

Donate