How can i rebuild this menu

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How can i rebuild this menu

Postby sumdroid » Sat Mar 21, 2009 8:54 pm

hi,

can some tell me how i can rebuild this:
Image

this screenshot is from android google maps.
i will rebuild this radiobutton menu and this is my xml-code:


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <menu xmlns:android="http://schemas.android.com/apk/res/android">
  2.         <item android:id="@+id/menuobject_browse_map"
  3.               android:title="@string/menu_browse_map" />
  4.         <item android:id="@+id/menuobject_last_search_results"
  5.               android:title="@string/menu_last_search_results" />
  6.         <item android:id="@+id/menuobject_send_message"
  7.               android:title="@string/menu_send_message" />
  8.         <item android:id="@+id/menuobject_mapmode"
  9.               android:title="@string/menu_mapmode">
  10.               <menu xmlns:android="http://schemas.android.com/apk/res/android">
  11.                         <RadioGroup android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" >
  12.                                 <RadioButton android:id="@+id/menuobject_mapmode_map"
  13.                                           android:title="@string/menu_mapmode_map"/>
  14.                                 <RadioButton android:id="@+id/menuobject_mapmode_satellite"
  15.                                           android:title="@string/menu_mapmode_satellite"/>
  16.                         </RadioGroup>                  
  17.               </menu>
  18.         </item>
  19.         <item android:id="@+id/menuobject_grabed_objects"
  20.               android:title="@string/menu_grabed_objects" />
  21.         <item android:id="@+id/submenuobject_change_login"
  22.                   android:title="@string/submenu_change_login" />
  23.         <item android:id="@+id/submenuobject_message_history"
  24.                   android:title="@string/submenu_message_history" />
  25.         <item android:id="@+id/submenuobject_about"
  26.                   android:title="@string/submenu_about" />
  27.         <item android:id="@+id/submenuobject_exit"
  28.                   android:title="@string/submenu_exit" />
  29. </menu>
  30.  
  31.  
Parsed in 0.005 seconds, using GeSHi 1.0.8.4
sumdroid
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Mar 18, 2009 3:54 pm

Top

Postby sumdroid » Thu Mar 26, 2009 4:32 pm

is this rocked science or why can nobody help me? :roll:
sumdroid
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Mar 18, 2009 3:54 pm

Postby kanzlr » Thu Mar 26, 2009 5:54 pm

what exactly is your problem?

define a layout:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.  
  3.    android:layout_width="fill_parent"
  4.  
  5.    android:layout_height="fill_parent"
  6.  
  7.    android:orientation="vertical">
  8.  
  9.     <RadioGroup
  10.  
  11.        android:layout_width="fill_parent"
  12.  
  13.        android:layout_height="wrap_content"
  14.  
  15.        android:orientation="vertical"
  16.  
  17.        android:checkedButton="@+id/lunch"
  18.  
  19.        android:id="@+id/mapmenu">
  20.  
  21.         <RadioButton
  22.  
  23.            android:text="Map"
  24.  
  25.            android:id="@+id/breakfast"
  26.  
  27.            />
  28.  
  29.         <RadioButton
  30.  
  31.            android:text="Traffic"
  32.  
  33.            android:id="@id/lunch" />
  34.  
  35.         <RadioButton
  36.  
  37.            android:text="Satellite"
  38.  
  39.            android:id="@+id/dinner" />
  40.  
  41.         <RadioButton
  42.  
  43.            android:text="Streetview"
  44.  
  45.            android:id="@+id/all" />      
  46.  
  47.     </RadioGroup>
  48.  
  49. </LinearLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


and use it for a dialog:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. LayoutInflater factory = LayoutInflater.from(this);
  2.  
  3.                         final View radioButtons = factory.inflate(R.layout.mapmenu,
  4.  
  5.                                         null);
  6.  
  7.                         return new AlertDialog.Builder(this).setTitle(
  8.  
  9.                                         "Map").setView(radioButtons)
  10.  
  11.                                         .create();
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


you should also add listeners to the group, so you can close the dialog on change.
kanzlr
Developer
Developer
 
Posts: 25
Joined: Sun Mar 15, 2009 4:44 pm
Location: Vienna/Austria/EU

Postby sumdroid » Fri Mar 27, 2009 11:52 am

thx for the reply.

i build the radiomenu, how you can see in my first post, inside the main menu. i thought android would process this xml-bunch and put my menu out. or is there a definition-mistake? With normal menu items this principle works fine.
sumdroid
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Mar 18, 2009 3:54 pm

Postby kanzlr » Fri Mar 27, 2009 11:55 am

hm, I am not sure it works that way? a menu in a menu? haven't tried that myself :)
kanzlr
Developer
Developer
 
Posts: 25
Joined: Sun Mar 15, 2009 4:44 pm
Location: Vienna/Austria/EU

Postby sumdroid » Fri Mar 27, 2009 12:04 pm

yes, this works. ;)
but a group radiobuttons as a submenu in a menu throws nothing. not even an error. :(
sumdroid
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Mar 18, 2009 3:54 pm

Top

Postby sumdroid » Sat Mar 28, 2009 9:34 pm

thx for your help again.

but one question. should i use onCreate "constructor" or which abstract-function is the right one?
sumdroid
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Mar 18, 2009 3:54 pm

Postby kanzlr » Sun Mar 29, 2009 6:36 pm

onCreate is called everytime your activity is created. so basically when your app starts.
so yes, this is where you do this stuff.
kanzlr
Developer
Developer
 
Posts: 25
Joined: Sun Mar 15, 2009 4:44 pm
Location: Vienna/Austria/EU

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests