<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Android_Studio%3A_Cara_Membuat_Android_Apps_4</id>
	<title>Android Studio: Cara Membuat Android Apps 4 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Android_Studio%3A_Cara_Membuat_Android_Apps_4"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Android_Studio:_Cara_Membuat_Android_Apps_4&amp;action=history"/>
	<updated>2026-04-20T14:20:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=Android_Studio:_Cara_Membuat_Android_Apps_4&amp;diff=42694&amp;oldid=prev</id>
		<title>Onnowpurbo: New page: In this video tutorial I will cover how to make menus and dialog popups. I’ll specifically cover laying out menus in main.xml, DialogFragment, AlertDialog, Action Bars, Option Menus and ...</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Android_Studio:_Cara_Membuat_Android_Apps_4&amp;diff=42694&amp;oldid=prev"/>
		<updated>2015-03-18T03:24:09Z</updated>

		<summary type="html">&lt;p&gt;New page: In this video tutorial I will cover how to make menus and dialog popups. I’ll specifically cover laying out menus in main.xml, DialogFragment, AlertDialog, Action Bars, Option Menus and ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In this video tutorial I will cover how to make menus and dialog popups. I’ll specifically cover laying out menus in main.xml, DialogFragment, AlertDialog, Action Bars, Option Menus and more.&lt;br /&gt;
&lt;br /&gt;
If you missed the first videos they are here How to Make Android apps 1, 2, and 3. Definitely watch them first. All of the code follows the video below. It is heavily commented to help you learn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you like videos like this, it helps me if you share on Google Plus with a click here&lt;br /&gt;
&lt;br /&gt;
Code from the Video&lt;br /&gt;
&lt;br /&gt;
main.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;menu xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;&lt;br /&gt;
    xmlns:app=&amp;quot;http://schemas.android.com/apk/res-auto&amp;quot;&lt;br /&gt;
    xmlns:tools=&amp;quot;http://schemas.android.com/tools&amp;quot;&lt;br /&gt;
    tools:context=&amp;quot;com.newthinktank.menuexamples2.app.MainActivity&amp;quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- The Options or Overflow menu is located in the upper right hand&lt;br /&gt;
    corner for devices running Android 4.0 and above.&lt;br /&gt;
    To make this menu use the menu element and define each option in an&lt;br /&gt;
    item element.&lt;br /&gt;
&lt;br /&gt;
    orderInCategory defines the order of appearance&lt;br /&gt;
&lt;br /&gt;
    showAsAction defines that the item should appear on the action bar&lt;br /&gt;
    if there is enough room or not. If you want to support the Action Bar&lt;br /&gt;
    for versions of Android below 2.1 use your apps name space instead of&lt;br /&gt;
    android so you can use import android.support.v7.app.ActionBarActivity;&lt;br /&gt;
    Use withText to show the title in the action bar&lt;br /&gt;
    icon defines a icon to use for the item&lt;br /&gt;
&lt;br /&gt;
    checkableBehavior is used to allow the user to select a single or all&lt;br /&gt;
    items when the menu items are surrounded by group --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;group android:checkableBehavior=&amp;quot;single&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;item android:id=&amp;quot;@+id/action_settings&amp;quot;&lt;br /&gt;
        android:title=&amp;quot;@string/action_settings&amp;quot;&lt;br /&gt;
        android:orderInCategory=&amp;quot;100&amp;quot;&lt;br /&gt;
        app:showAsAction=&amp;quot;never&amp;quot;&lt;br /&gt;
        android:icon=&amp;quot;@drawable/sunny&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;item android:id=&amp;quot;@+id/exit_the_app&amp;quot;&lt;br /&gt;
        android:title=&amp;quot;@string/options_exit_text&amp;quot;&lt;br /&gt;
        app:showAsAction=&amp;quot;ifRoom|withText&amp;quot;&lt;br /&gt;
        android:orderInCategory=&amp;quot;101&amp;quot;&lt;br /&gt;
        android:icon=&amp;quot;@drawable/night&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/group&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/menu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MainActivity.java&lt;br /&gt;
&lt;br /&gt;
package com.newthinktank.menuexamples2.app;&lt;br /&gt;
&lt;br /&gt;
import android.app.DialogFragment;&lt;br /&gt;
import android.os.Bundle;&lt;br /&gt;
import android.support.v7.app.ActionBarActivity;&lt;br /&gt;
import android.view.Menu;&lt;br /&gt;
import android.view.MenuItem;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class MainActivity extends ActionBarActivity {&lt;br /&gt;
&lt;br /&gt;
    @Override&lt;br /&gt;
    protected void onCreate(Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.activity_main);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    // This method creates the menu on the app&lt;br /&gt;
    @Override&lt;br /&gt;
    public boolean onCreateOptionsMenu(Menu menu) {&lt;br /&gt;
&lt;br /&gt;
        // Inflate the menu; this adds items to the action bar if it is present.&lt;br /&gt;
        getMenuInflater().inflate(R.menu.main, menu);&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Called when a options menu item is selected&lt;br /&gt;
    @Override&lt;br /&gt;
    public boolean onOptionsItemSelected(MenuItem item) {&lt;br /&gt;
        // Handle action bar item clicks here. The action bar will&lt;br /&gt;
        // automatically handle clicks on the Home/Up button, so long&lt;br /&gt;
        // as you specify a parent activity in AndroidManifest.xml.&lt;br /&gt;
        int id = item.getItemId();&lt;br /&gt;
&lt;br /&gt;
        // We check what menu item was clicked and show a Toast&lt;br /&gt;
        if (id == R.id.action_settings) {&lt;br /&gt;
&lt;br /&gt;
            // A DialogFragment is a Fragment you can place over top&lt;br /&gt;
            // the current Activity. A Fragment is like an interface&lt;br /&gt;
            // block that you can place into an Activity.&lt;br /&gt;
            // The FrgamentManager allows you to interact with the&lt;br /&gt;
            // Fragment&lt;br /&gt;
            DialogFragment myFragment = new MyDialogFragment();&lt;br /&gt;
&lt;br /&gt;
            myFragment.show(getFragmentManager(), &amp;quot;theDialog&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            return true;&lt;br /&gt;
&lt;br /&gt;
            // If exit was clicked close the app&lt;br /&gt;
        } else if (id == R.id.exit_the_app) {&lt;br /&gt;
            finish();&lt;br /&gt;
            return true;&lt;br /&gt;
        }&lt;br /&gt;
        return super.onOptionsItemSelected(item);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
MyDialogFragment.java&lt;br /&gt;
&lt;br /&gt;
package com.newthinktank.menuexamples2.app;&lt;br /&gt;
&lt;br /&gt;
// This will be used to create a dialog window&lt;br /&gt;
&lt;br /&gt;
import android.app.AlertDialog;&lt;br /&gt;
import android.app.Dialog;&lt;br /&gt;
import android.app.DialogFragment;&lt;br /&gt;
import android.content.DialogInterface;&lt;br /&gt;
import android.os.Bundle;&lt;br /&gt;
import android.widget.Toast;&lt;br /&gt;
&lt;br /&gt;
// If you get an error that the minimum must be 11, change the minimum in the manifest&lt;br /&gt;
// and also change it in build.gradle&lt;br /&gt;
&lt;br /&gt;
// To generate the onCreateDialog() right click on DialogFragment and Generate and&lt;br /&gt;
// select onCreateDialog()&lt;br /&gt;
&lt;br /&gt;
public class MyDialogFragment extends DialogFragment{&lt;br /&gt;
    @Override&lt;br /&gt;
    public Dialog onCreateDialog(Bundle savedInstanceState) {&lt;br /&gt;
&lt;br /&gt;
        // We build the dialog&lt;br /&gt;
        // getActivity() returns the Activity this Fragment is associated with&lt;br /&gt;
        AlertDialog.Builder theDialog = new AlertDialog.Builder(getActivity());&lt;br /&gt;
&lt;br /&gt;
        // Set the title for the Dialog&lt;br /&gt;
        theDialog.setTitle(&amp;quot;Sample Dialog&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        // Set the message&lt;br /&gt;
        theDialog.setMessage(&amp;quot;Hello I&amp;#039;m a Dialog&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        // Add text for a positive button&lt;br /&gt;
        theDialog.setPositiveButton(&amp;quot;OK&amp;quot;, new DialogInterface.OnClickListener() {&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onClick(DialogInterface dialogInterface, int i) {&lt;br /&gt;
&lt;br /&gt;
                Toast.makeText(getActivity(), &amp;quot;Clicked OK&amp;quot;, Toast.LENGTH_SHORT).show();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        // Add text for a negative button&lt;br /&gt;
        theDialog.setNegativeButton(&amp;quot;CANCEL&amp;quot;, new DialogInterface.OnClickListener() {&lt;br /&gt;
            @Override&lt;br /&gt;
            public void onClick(DialogInterface dialogInterface, int i) {&lt;br /&gt;
&lt;br /&gt;
                Toast.makeText(getActivity(), &amp;quot;Clicked Cancel&amp;quot;, Toast.LENGTH_SHORT).show();&lt;br /&gt;
&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
        // Returns the created dialog&lt;br /&gt;
        return theDialog.create();&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
AndroidManifest.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;manifest xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;&lt;br /&gt;
    package=&amp;quot;com.newthinktank.menuexamples2.app&amp;quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;uses-sdk&lt;br /&gt;
        android:minSdkVersion=&amp;quot;11&amp;quot;&lt;br /&gt;
        android:targetSdkVersion=&amp;quot;19&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;application&lt;br /&gt;
        android:allowBackup=&amp;quot;true&amp;quot;&lt;br /&gt;
        android:icon=&amp;quot;@drawable/ic_launcher&amp;quot;&lt;br /&gt;
        android:label=&amp;quot;@string/app_name&amp;quot;&lt;br /&gt;
        android:theme=&amp;quot;@style/AppTheme&amp;quot; &amp;gt;&lt;br /&gt;
        &amp;lt;activity&lt;br /&gt;
            android:name=&amp;quot;com.newthinktank.menuexamples2.app.MainActivity&amp;quot;&lt;br /&gt;
            android:label=&amp;quot;@string/app_name&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;intent-filter&amp;gt;&lt;br /&gt;
                &amp;lt;action android:name=&amp;quot;android.intent.action.MAIN&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;category android:name=&amp;quot;android.intent.category.LAUNCHER&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/intent-filter&amp;gt;&lt;br /&gt;
        &amp;lt;/activity&amp;gt;&lt;br /&gt;
    &amp;lt;/application&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/manifest&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- See more at: http://www.newthinktank.com/2014/06/make-android-apps-4/#sthash.2X7oJHNf.dpuf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Referensi==&lt;br /&gt;
&lt;br /&gt;
* http://www.newthinktank.com/2014/06/make-android-apps-4/&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>