隨筆-348  評論-598  文章-0  trackbacks-0
          聲明一個Activity,使用ACTION_MAIN作為Action,CATEGORY_DEFAULT作為Category,之后在調用Activity中,引入如下代碼就可以自動生成所有匹配Action和Category的Activity的啟動菜單了。
          @Override
              
          public boolean onCreateOptionsMenu(Menu menu){
                  Log.i(
          "TestActivity""Options Menu Created");
                  
          super.onCreateOptionsMenu(menu);
                  
          //menu.add(1, 0, 0, "EDIT");

                  
          // Create an Intent that describes the requirements to fulfill, to be included
                  
          // in our menu. The offering app must include a category value of Intent.CATEGORY_ALTERNATIVE. 
                  Intent intent = new Intent(Intent.ACTION_MAIN, getIntent().getData());
                  intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
                      
                  
          // Search for, and populate the menu with, acceptable offering applications.
                  menu.addIntentOptions(
                       
          1,  // Menu group 
                       0,      // Unique item ID (none)
                       0,      // Order for the items (none)
                       this.getComponentName(),   // The current Activity name
                       null,   // Specific items to place first (none)
                       intent, // Intent created above that describes our requirements
                       0,      // Additional flags to control items (none)
                       null);  // Array of MenuItems that corrolate to specific items (none)

                  
          return true;
              }


          ---------------------------------------------------------
          專注移動開發

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2010-01-31 19:32 TiGERTiAN 閱讀(982) 評論(0)  編輯  收藏 所屬分類: Java 、Android
          主站蜘蛛池模板: 扬州市| 沅陵县| 临安市| 蒲江县| 海口市| 内江市| 华容县| 永昌县| 婺源县| 边坝县| 保德县| 武陟县| 龙山县| 泰安市| 利川市| 安阳市| 诸暨市| 白山市| 平陆县| 土默特左旗| 安龙县| 巢湖市| 金乡县| 宁化县| 永靖县| 东莞市| 正安县| 南召县| 凌海市| 张北县| 华容县| 都兰县| 潜山县| 祥云县| 平潭县| 慈溪市| 洪湖市| 沐川县| 梧州市| 柳州市| 大冶市|