{"id":663,"date":"2011-01-05T03:00:47","date_gmt":"2011-01-05T08:00:47","guid":{"rendered":"httpss:\/\/www.powenko.com\/wordpress\/?p=663"},"modified":"2014-11-16T22:36:01","modified_gmt":"2014-11-17T03:36:01","slug":"android-ui-dialog","status":"publish","type":"post","link":"https:\/\/www.powenko.com\/wordpress\/?p=663","title":{"rendered":"android, ui, dialog"},"content":{"rendered":"<p><a rel=\"attachment wp-att-665\" href=\"httpss:\/\/www.powenko.com\/wordpress\/?attachment_id=665\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-665\" title=\"toast\" src=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2011\/01\/toast-228x300.png\" alt=\"\" width=\"228\" height=\"300\" \/><\/a><\/p>\n<p><a rel=\"attachment wp-att-666\" href=\"httpss:\/\/www.powenko.com\/wordpress\/?attachment_id=666\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-666\" title=\"alert\" src=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2011\/01\/alert-248x300.png\" alt=\"\" width=\"248\" height=\"300\" \/><\/a><\/p>\n<p><a rel=\"attachment wp-att-667\" href=\"httpss:\/\/www.powenko.com\/wordpress\/?attachment_id=667\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-667\" title=\"okbtn\" src=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2011\/01\/okbtn-229x300.png\" alt=\"\" width=\"229\" height=\"300\" \/><\/a><\/p>\n<p><a rel=\"attachment wp-att-668\" href=\"httpss:\/\/www.powenko.com\/wordpress\/?attachment_id=668\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-668\" title=\"yesno\" src=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2011\/01\/yesno-249x300.png\" alt=\"\" width=\"249\" height=\"300\" \/><\/a><\/p>\n<p><a rel=\"attachment wp-att-669\" href=\"httpss:\/\/www.powenko.com\/wordpress\/?attachment_id=669\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-669\" title=\"progress\" src=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2011\/01\/progress-266x300.png\" alt=\"\" width=\"266\" height=\"300\" \/><\/a><\/p>\n<pre class=\"Java\" cols=\"60\" rows=\"10\" name=\"code\">    \r\n   \r\n\r\npackage com.powenko.TutorialDialogCumtomerWithButton;\r\n\r\nimport android.app.Activity;\r\nimport android.os.Bundle;\r\nimport android.view.View.OnClickListener;\r\nimport android.view.View;\r\nimport android.widget.Button;\r\nimport android.widget.Toast;\r\nimport android.app.AlertDialog;\r\nimport android.content.DialogInterface;\r\nimport android.app.ProgressDialog;\r\n\r\npublic class TutorialDialogCumtomerWithButton extends Activity implements OnClickListener {\r\n\r\n@Override\r\npublic void onCreate(Bundle savedInstanceState) {\r\nsuper.onCreate(savedInstanceState);\r\nsetContentView(R.layout.main);\r\n\r\n\/\/ set a click listener on the toast button\r\nButton toast = (Button) findViewById(R.id.toastbtn);\r\ntoast.setOnClickListener(this);\r\n\r\n\/\/ set a click listener on the alert button\r\nButton alert = (Button) findViewById(R.id.alertbtn);\r\nalert.setOnClickListener(this);\r\n\r\n\/\/ set a click listener on the yesno button\r\nButton yesno = (Button) findViewById(R.id.yesnobtn);\r\nyesno.setOnClickListener(this);\r\n\r\n\/\/ set a click listener on the progress button\r\nButton progress = (Button) findViewById(R.id.progressbtn);\r\nprogress.setOnClickListener(this);\r\n}\r\n\r\npublic void onClick(View view) {\r\n\/\/ which button is clicked?\r\n\r\n\/\/ the Toast button\r\nif (view == findViewById(R.id.toastbtn)) {\r\n\/\/ display the toast popup window\r\nToast.makeText(this, \"This is the Toast message\", Toast.LENGTH_LONG).show();\r\n}\r\n\r\n\/\/ the Alert button the activated\r\nif (view == findViewById(R.id.alertbtn)) {\r\n\r\n\/\/ prepare the alert box\r\nAlertDialog.Builder alertbox = new AlertDialog.Builder(this);\r\n\r\n\/\/ set the message to display\r\nalertbox.setMessage(\"This is the alertbox!\");\r\n\r\n\/\/ add a neutral button to the alert box and assign a click listener\r\nalertbox.setNeutralButton(\"Ok\", new DialogInterface.OnClickListener() {\r\n\r\n\/\/ click listener on the alert box\r\npublic void onClick(DialogInterface arg0, int arg1) {\r\n\/\/ the button was clicked\r\nToast.makeText(getApplicationContext(), \"OK button clicked\", Toast.LENGTH_LONG).show();\r\n}\r\n});\r\n\r\n\/\/ show it\r\nalertbox.show();\r\n}\r\n\r\n\/\/ the yesno button is clicked\r\nif (view == findViewById(R.id.yesnobtn)) {\r\n\/\/ prepare the alert box\r\nAlertDialog.Builder alertbox = new AlertDialog.Builder(this);\r\n\r\n\/\/ set the message to display\r\nalertbox.setMessage(\"This is the alertbox!\");\r\n\r\n\/\/ set a positive\/yes button and create a listener\r\nalertbox.setPositiveButton(\"Yes\", new DialogInterface.OnClickListener() {\r\n\r\n\/\/ do something when the button is clicked\r\npublic void onClick(DialogInterface arg0, int arg1) {\r\nToast.makeText(getApplicationContext(), \"'Yes' button clicked\", Toast.LENGTH_SHORT).show();\r\n}\r\n});\r\n\r\n\/\/ set a negative\/no button and create a listener\r\nalertbox.setNegativeButton(\"No\", new DialogInterface.OnClickListener() {\r\n\r\n\/\/ do something when the button is clicked\r\npublic void onClick(DialogInterface arg0, int arg1) {\r\nToast.makeText(getApplicationContext(), \"'No' button clicked\", Toast.LENGTH_SHORT).show();\r\n}\r\n});\r\n\r\n\/\/ display box\r\nalertbox.show();\r\n}\r\n\r\n\/\/ progress button clicked\r\nif (view == findViewById(R.id.progressbtn)) {\r\n\/\/ prepare the dialog box\r\nProgressDialog dialog = new ProgressDialog(this);\r\n\r\n\/\/ make the progress bar cancelable\r\ndialog.setCancelable(true);\r\n\r\n\/\/ set a message text\r\ndialog.setMessage(\"Loading...\");\r\n\r\n\/\/ show it\r\ndialog.show();\r\n}\r\n\r\n}\r\n}\r\n<\/pre>\n<pre class=\"Java\" cols=\"60\" rows=\"10\" name=\"code\">    \r\n   \r\n\r\n\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<LinearLayout xmlns:android=\"httpss:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:orientation=\"vertical\"\r\n    android:layout_width=\"fill_parent\"\r\n    android:layout_height=\"fill_parent\"\r\n    >\r\n \r\n<Button android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"Show Toast\" android:id=\"@+id\/toastbtn\"><\/Button>\r\n<Button android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"Show Alert\" android:id=\"@+id\/alertbtn\"><\/Button>\r\n<Button android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"Show Yes\/No\" android:id=\"@+id\/yesnobtn\"><\/Button>\r\n<Button android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"Show Progress\" android:id=\"@+id\/progressbtn\"><\/Button>\r\n<\/LinearLayout>\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>package com.powenko.TutorialDialogCumtomerWithButton; i [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":666,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[],"class_list":["post-663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ui"],"_links":{"self":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/663"}],"collection":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=663"}],"version-history":[{"count":12,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/663\/revisions"}],"predecessor-version":[{"id":727,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/663\/revisions\/727"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/media\/666"}],"wp:attachment":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}