Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - How to manipulate menu during runtime?

How to manipulate menu during runtime?

Put your problem here if it does not fit any of the other categories.

How to manipulate menu during runtime?

Postby frog » Thu Jan 24, 2008 3:53 pm

Hallo,

i initialize my menu with help of the callback method "public boolean onCreateOptionsMenu(Menu menu)". In this method i also create some member reference to the handed over menu and items i create.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         public boolean onCreateOptionsMenu(Menu menu)
  3.  
  4.         {
  5.  
  6.                 this.menu = menu;
  7.  
  8.                 this.menuPlayItem = menu.add(1, 1, "play");
  9.  
  10.                 this.menuPlayItem.setShown(true);
  11.  
  12.                 return super.onCreateOptionsMenu(menu);
  13.  
  14.         }
  15.  
  16.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


During runtime i want to manipulate the menu and items but the references i created before are pointing to null!

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         public void someMethod()
  3.  
  4.         {
  5.  
  6.                 // nullpointer exception
  7.  
  8.                 this.menuPlayItem.setShown(false);
  9.  
  10.         }
  11.  
  12.  
Parsed in 0.010 seconds, using GeSHi 1.0.8.4



any suggestions? tipps? isn't it possible to manipulate the menu outside of "onCreateOptionsMenu"?

the menu is there and selectable and so the references SHOULD point to something useful because "onCreateOptionsMenu" was run successful.

greetings from the java frog
frog
Freshman
Freshman
 
Posts: 2
Joined: Wed Jan 16, 2008 11:03 am
Location: Germany

Top

Postby x-files » Thu Jan 24, 2008 4:06 pm

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.  
  3.     public boolean onPrepareOptionsMenu(Menu menu) {
  4.  
  5.         boolean res = super.onPrepareOptionsMenu(menu);
  6.  
  7.         boolean haveItems = manager.size() > 0;
  8.  
  9.         menu.setItemShown(SELECT_ID, haveItems);
  10.  
  11.         menu.setItemShown(DELETE_ID, haveItems);
  12.  
  13.         return res;
  14.  
  15.     }
Parsed in 0.010 seconds, using GeSHi 1.0.8.4
x-files
Developer
Developer
 
Posts: 44
Joined: Fri Jan 11, 2008 10:27 am

Postby frog » Wed Jan 30, 2008 2:58 pm

ok - really simple solution - somehow i missed it in the documentation :oops: :roll:

thx
frog
Freshman
Freshman
 
Posts: 2
Joined: Wed Jan 16, 2008 11:03 am
Location: Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot], MSNbot Media and 12 guests