隨筆-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 閱讀(984) 評論(0)  編輯  收藏 所屬分類: JavaAndroid
          主站蜘蛛池模板: 清徐县| 文山县| 通渭县| 五家渠市| 九龙城区| 宜君县| 东乌珠穆沁旗| 饶阳县| 大关县| 徐水县| 仪征市| 康定县| 务川| 临猗县| 兴安县| 当雄县| 富平县| 吉木萨尔县| 菏泽市| 冷水江市| 思南县| 兴山县| 开封市| 晋江市| 武乡县| 中卫市| 普兰县| 蒙自县| 齐河县| 和龙市| 依安县| 日土县| 扬中市| 浦县| 巴彦淖尔市| 遂宁市| 融水| 江西省| 宜章县| 通渭县| 渭源县|