Skip to content Skip to sidebar Skip to footer

Split Action Bar - Creating Menu After Clicking An Item

I want to create something like this : So far what I've done : public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_layer:

Solution 1:

What you see in that Maps app is a custom dialog. You can indeed make your own, fully customized dialogs. Create a layout, just like your Activity layout (say custom_dialog.xml)

<LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"
><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:text="Hey!"
   /><ListViewandroid:layout_width="match_parent"android:layout_height="match_parent"
   /></LinearLayout>

Put this file into projects /layout folder.

And put this code to Activity's onCreateDialog(int), where you create dialogs that you want to show.

Dialogdialog=newDialog(getApplicationContext());
dialog.setContentView(R.layout.custom_dialog);

[... misc. initialization]

I tried to simply answer your question but there is plenty of source available and Android's API Guide fully explains how to create and customize Dialogs.

Post a Comment for "Split Action Bar - Creating Menu After Clicking An Item"