Home > Android > Android Program – Options Menu

Android Program – Options Menu

ANDROID

 

Android Program – Options Menu

         

Java Code(OptionAct)

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;

public class OptionAct extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_option);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
MenuInflater mi = getMenuInflater();
mi.inflate(R.menu.menu_example1,menu);
return true;
}
public void view1(View v)
{
Intent i=new Intent(OptionAct.this,OptionNext.class);
startActivity(i);
}

}

Layout XML Code(activity_option)

<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout 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:orientation=”vertical”
android:paddingBottom=”@dimen/activity_vertical_margin”
android:paddingLeft=”@dimen/activity_horizontal_margin”
android:paddingRight=”@dimen/activity_horizontal_margin”
android:paddingTop=”@dimen/activity_vertical_margin”
tools:context=”com.andro.tech.androidproject.OptionAct”>

<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:textSize=”30sp”
android:layout_gravity=”center”
android:textStyle=”bold”
android:text=”OPTIONS MENU”
android:layout_marginBottom=”280dp” />

<Button
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/sourcecode”
android:background=”@color/bgcolor”
android:textStyle=”bold”
android:textColor=”@color/text”
android:onClick=”view1″/>

</LinearLayout>

Output:

         

Download Source Code

Follow Us – Never Miss Update

Fb/PageTwitterGoogle+InstagramPinterest 



[metaslider id=3165]

Recent   

 

Is this Useful content For You?