Search Wikipedia

Search results

Showing posts with label Content menu. Show all posts
Showing posts with label Content menu. Show all posts

Oct 18, 2013

Content menu in Android

  Creating a Content Menu


Android has a unique mechanism called long press.
 When we click any button or image for long time a kind of menu appears that is called content menu.

Today i am doing a project related to this.
First of all i create a project called "Content_menu".
Then go to XML file.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

activity_main.xml


<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"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="106dp"
        android:layout_marginTop="159dp"
        android:text="@string/button" />
</RelativeLayout>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Adding a button in xml

Then i create a new xml file called contentmenu.xml
Note: Choose menu in Resource Type

Creating a new XML file

}