jon waek
Crypto Compliance Analyst
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
400 XP
Operating System
Android
In this tutorial we will try to create a Simple Alert Dialog Using Android. Android is the world’s most widely used operating system with over a millions of user, that are already installed to smartphones, tablets, and even television. Android is an open source so that developer find it easy to develop and expand new features. So let's do the coding...
Getting Started:
First you will have to download & install the Android Development IDE (Android Studio or Eclipse). Android Studio is an open source development feel free to develop your things.
Here's the link for the Android Studio https://developer.android.com/studio/index.html.
Layout Design
We will now create the design for the application, first locate the activity_main.xml and click text to view the script. Then copy and paste the code below.
Android Manifest File
The Android Manifest file provides essential information about your app to the Android system in which the system must required before running the code.
The Main Function
This code contains the main function of the application. This code will generate a dialog to prompt the user to what to do next when the button is clicked. To create first locate your java file and open it, then write these blocks of code.
There you have it we successfully created a Simple Alert Dialog using android. I hope that this tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Download
Android
In this tutorial we will try to create a Simple Alert Dialog Using Android. Android is the world’s most widely used operating system with over a millions of user, that are already installed to smartphones, tablets, and even television. Android is an open source so that developer find it easy to develop and expand new features. So let's do the coding...
Getting Started:
First you will have to download & install the Android Development IDE (Android Studio or Eclipse). Android Studio is an open source development feel free to develop your things.
Here's the link for the Android Studio https://developer.android.com/studio/index.html.
Layout Design
We will now create the design for the application, first locate the activity_main.xml and click text to view the script. Then copy and paste the code below.
- <?
xml version=
"1.0"
encoding=
"utf-8"
?>
- <
RelativeLayout xmlns:
android=
"http://schemas.android.com/apk/res/android"
- xmlns:
app=
"http://schemas.android.com/apk/res-auto"
- xmlns:
tools=
"http://schemas.android.com/tools"
- android:
layout_width=
"match_parent"
- android:
layout_height=
"match_parent"
- tools:
context=
"com.razormist.simplealertdialog.MainActivity"
>
- <
TextView
- android:
layout_height=
"wrap_content"
- android:
layout_width=
"wrap_content"
- android:
text=
"Simple Alert Dialog"
- android:
textSize=
"30sp"
- android:
layout_alignParentTop=
"true"
- android:
layout_centerHorizontal=
"true"
- android:
layout_marginTop=
"20dp"
- android:
id=
"@+id/tv_title"
/>
- <
Button
- android:
id=
"@+id/btn_click"
- android:
layout_width=
"wrap_content"
- android:
layout_height=
"wrap_content"
- android:
layout_centerInParent=
"true"
- android:
text=
"Click Here"
/>
- </
RelativeLayout>
Android Manifest File
The Android Manifest file provides essential information about your app to the Android system in which the system must required before running the code.
- <?
xml version=
"1.0"
encoding=
"utf-8"
?>
- <
manifest xmlns:
android=
"http://schemas.android.com/apk/res/android"
- package
=
"com.razormist.simplealertdialog"
>
- <
application
- android:
allowBackup=
"true"
- android:
icon=
"@mipmap/ic_launcher"
- android:
label=
"@string/app_name"
- android:
roundIcon=
"@mipmap/ic_launcher_round"
- android:
supportsRtl=
"true"
- android:
theme=
"@Style/AppTheme"
>
- <
activity android:
name=
".MainActivity"
- android:
configChanges=
"orientation"
- android:
screenOrientation=
"portrait"
>
- <
intent-
filter>
- <
action android:
name=
"android.intent.action.MAIN"
/>
- <
category android:
name=
"android.intent.category.LAUNCHER"
/>
- </
intent-
filter>
- </
activity>
- </
application>
- </
manifest>
The Main Function
This code contains the main function of the application. This code will generate a dialog to prompt the user to what to do next when the button is clicked. To create first locate your java file and open it, then write these blocks of code.
- package
com.razormist.simplealertdialog
;
- import
android.app.Application
;
- import
android.content.DialogInterface
;
- import
android.support.v7.app.AlertDialog
;
- import
android.support.v7.app.AppCompatActivity
;
- import
android.os.Bundle
;
- import
android.util.Log
;
- import
android.view.View
;
- import
android.widget.Button
;
- import
android.widget.TextView
;
- public
class
MainActivity extends
AppCompatActivity {
- Button
btn_click;
- @Override
- protected
void
onCreate(
Bundle savedInstanceState)
{
- super
.onCreate
(
savedInstanceState)
;
- setContentView(
R.layout
.activity_main
)
;
- btn_click =
(
Button
)
findViewById(
R.id
.btn_click
)
;
- btn_click.setOnClickListener
(
new
View
.OnClickListener
(
)
{
- @Override
- public
void
onClick(
View
v)
{
- AlertDialog.Builder
builder=
new
AlertDialog.Builder
(
MainActivity.this
)
;
- builder.setMessage
(
"Are you sure you want to exit?"
)
- .setTitle
(
"System Configuration"
)
- .setCancelable
(
false
)
- .setPositiveButton
(
"YES"
, new
DialogInterface.OnClickListener
(
)
{
- @Override
- public
void
onClick(
DialogInterface dialog, int
which)
{
- moveTaskToBack(
true
)
;
- android.os
.Process
.killProcess
(
android.os
.Process
.myPid
(
)
)
;
- System
.exit
(
1
)
;
- }
}
)
- .setNegativeButton
(
"NO"
, new
DialogInterface.OnClickListener
(
)
{
- @Override
- public
void
onClick(
DialogInterface dialog, int
which)
{
- dialog.cancel
(
)
;
- }
- }
)
;
- AlertDialog alert =
builder.create
(
)
;
- alert.show
(
)
;
- }
- }
)
;
- }
- }
There you have it we successfully created a Simple Alert Dialog using android. I hope that this tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Download
You must upgrade your account or reply in the thread to view the hidden content.