Adly
Adly

Reputation: 597

menu in android but without menu button

I want to make a menu in my android app but I don't want that one which appears by pressing menu button, I just want it to be appeared without that.

Example : This is Google maps app on android I want to show such menu in the bottom while app is running without menu button. I hope that someone got what I want exactly :)

Google Maps app

Thanks a lot.

Upvotes: 0

Views: 722

Answers (3)

Navarr
Navarr

Reputation: 3764

What you're looking at is a Spinner that has been placed on an ActionBar.

Android's website has a tutorial on spinners that you can find at http://developer.android.com/resources/tutorials/views/hello-spinner.html

Upvotes: 0

redandblack
redandblack

Reputation: 526

You can yse RelativeLayout to do this. For example:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true" >

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <ImageButton
                android:id="@+id/imageButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/icon" />
        </LinearLayout>
    </RelativeLayout>
</RelativeLayout>

Upvotes: 0

Android Stack
Android Stack

Reputation: 4314

if you just need menu do the the following :

 public class Test extends ListActivity {
 String classes[] = { "first item", "second item", "third item", "fourth item"};

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setListAdapter(new ArrayAdapter<String>(Test.this,
            android.R.layout.simple_list_item_1, classes));
           }
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub
    super.onListItemClick(l, v, position, id);
    String planet = classes[position];
    try {
        Class ourClass = Class.forName("com.test.test." + planet);
        Intent ourIntent = new Intent(Test.this, ourClass);
        startActivity(ourIntent);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    }
   }

this code will not create to you menu like the above image, but it will give you the standerd menu and you can customize it as you wish .
hope this helpful .

Upvotes: 1

Related Questions