<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>android popup menu Archives -</title>
	<atom:link href="https://mitindia.in/tag/android-popup-menu/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/android-popup-menu/</link>
	<description></description>
	<lastBuildDate>Sat, 26 Nov 2016 07:29:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mitindia.in/wp-content/uploads/2023/03/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>android popup menu Archives -</title>
	<link>https://mitindia.in/tag/android-popup-menu/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Android Example to show Popup Menu</title>
		<link>https://mitindia.in/android-example-to-show-popup-menu/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Tue, 28 Jun 2016 06:16:30 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android popup menu]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=173</guid>

					<description><![CDATA[<p>In this tutorials you&#8217;ll see how &#8220;PopupMenu&#8221; app is created in Android. Have a look! 1. First of all copy the following code into &#8220;activity_main.xml&#8221; file &#60;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"&#62; &#60;TextView android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignRight="@+id/button1" android:layout_alignEnd="@+id/button1" android:textSize="20dp" android:textColor="#ff00ff"/&#62; &#60;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button1" android:text="Show popup" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /&#62; &#60;/RelativeLayout&#62; [&#8230;]</p>
<p>The post <a href="https://mitindia.in/android-example-to-show-popup-menu/">Android Example to show Popup Menu</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><strong><span style="color: #993300;">In this tutorials you&#8217;ll see how &#8220;PopupMenu&#8221; app is created in Android. Have a look!</span></strong></div>
<div>1. First of all copy the following code into &#8220;activity_main.xml&#8221; file</div>
<div>
<pre>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"&gt;

    &lt;TextView android:text="@string/hello_world" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignRight="@+id/button1"
        android:layout_alignEnd="@+id/button1"
        android:textSize="20dp"
        android:textColor="#ff00ff"/&gt;


    &lt;Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/button1"
        android:text="Show popup"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" /&gt;

&lt;/RelativeLayout&gt;


2. Copy the following code into "Main_Menu.xml" file
&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"&gt;


    &lt;Item
        android:id="@+id/one"
        android:text="One"/&gt;

    &lt;Item
        android:id="@+id/two"
        android:text="Two"/&gt;

    &lt;Item
        android:id="@+id/three"
        android:text="Three"/&gt;

&lt;/menu&gt;
3. Now, copy the following code and paste into "MainActivity.Java" file
package app.mitindia.com.popupmenu;

import android.app.Activity;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.PopupMenu;
import android.widget.Toast;
import android.view.View.OnClickListener;

public class MainActivity extends Activity {

    Button button1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        button1 = (Button) findViewById(R.id.button1);
        button1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                PopupMenu popup = new PopupMenu(MainActivity.this, button1);

                popup.getMenuInflater().inflate(R.menu.menu_main, popup.getMenu());
                popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(MenuItem menuItem) {
                        Toast.makeText(MainActivity.this, "You Clicked :" + menuItem.getTitle(), Toast.LENGTH_LONG).show();

                        return false;
                    }
                });
                popup.show();

            }
        });

    }

}</pre>
</div>
<div>4. Run, and see the output as following screen shot.</div>
<div><img fetchpriority="high" decoding="async" class="alignnone" src="https://shivkblog.files.wordpress.com/2015/06/screenshot_2015-06-29-14-11-22.png?w=169" alt="Screenshot_2015-06-29-14-11-22" width="169" height="300" /></div>
<div></div>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fandroid-example-to-show-popup-menu%2F&amp;linkname=Android%20Example%20to%20show%20Popup%20Menu" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fandroid-example-to-show-popup-menu%2F&amp;linkname=Android%20Example%20to%20show%20Popup%20Menu" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fandroid-example-to-show-popup-menu%2F&#038;title=Android%20Example%20to%20show%20Popup%20Menu" data-a2a-url="https://mitindia.in/android-example-to-show-popup-menu/" data-a2a-title="Android Example to show Popup Menu"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/android-example-to-show-popup-menu/">Android Example to show Popup Menu</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
