Thinking in XiaoQiang
          世人皆有悲哀,只有你不明白
          posts - 56,comments - 150,trackbacks - 0
          android SDK中提供了TabHost使用起來很方便, 但是當tab比較多的時候,就會擠在一起,而不能橫向的滾動比較麻煩.

                于是我嘗試的制作了一個簡單的使用Gallery來代替TabHost的例子, 確實夠簡單的,自娛自樂.....僅供參考

           

               

           

                使用BroadcastReceiver來切換不同的Tab

           

              public class ChangeTabBroadcastReceiver extends BroadcastReceiver {
                  @Override
                  
          public void onReceive(Context context, Intent intent) {
                      
          int index = intent.getExtras().getInt(CURRENT_TAB_INDEX);
                      Log.i(TAG, 
          "onReceive index = " + index);
                      
          // setCurrentTab(index);
                      topBar.setSelection(index);
                      startGroupActivity(titleList.get(index).toString(),
                              (Intent) intentList.get(index));
                  }
              }

           

               沒有詳細研究SDK中的TabHost實現(xiàn)機制, 使用起來還是有些不方便的地方


          public class GalleryTabActivityDemo extends GalleryTabactivity {
              @Override
              
          public void onCreate(Bundle savedInstanceState) {
                  
          super.onCreate(savedInstanceState);
                  setDelegate(
          new SliderBarActivityDelegateImpl());
                  
          for (int i = 0; i < 14; i++) {
                      Intent intent;
                      
          if (i % 2 == 0)
                          intent 
          = new Intent(this, DemoActivity1.class);
                      
          else
                          intent 
          = new Intent(this, DemoActivity2.class);

                      
          this.addTab("title" + i, android.R.drawable.star_on, intent);

                  }
          //必須在addTab后調(diào)用commit, 有點麻煩, 將來會找更好的辦法
                  super.setup();
              }

          //可自定義切換tab時觸發(fā)的操作
              private class SliderBarActivityDelegateImpl extends
                      SliderBarActivityDelegate {
                  
          protected void onTabChanged(int tabIndex) {
                      Log.d(
          "onTabChanged""" + tabIndex);
                  }
              }
          }

          最近工作比較忙,沒太多時間學習android,將來會慢慢改善, 先湊合用, 拋塊磚先, 各位有玉的使勁砸, 金條也行

           下載

          posted @ 2010-05-13 15:46 小強 閱讀(2159) | 評論 (0)編輯 收藏
          學習android的練習小軟件.

           

              制作文件管理器的初衷是發(fā)現(xiàn)G1上并沒有隨系統(tǒng)附帶文件瀏覽軟件, 考慮到電子書,媒體播放器或其它一些軟件會使用到文件瀏覽,選擇文件或文件夾, 所以先做了這個文件管理工具并封裝一些參數(shù)供第三方程序調(diào)用

              應(yīng)用很簡單, 只是把手機和SD卡中的文件列出來, 支持圖片和mp3的簡單預覽. 未來會有更多的功能擴充進來. 歡迎大家試用并提出意見.

          --------------------------------------------------------4月更新0.3版 --------------------------------------------------------------------

          自從上次更新后工作太忙,半年沒玩兒ANDROID了, 最近剛剛閑下來, 繼續(xù)完善文件管理器

          順便封裝了一些其它的widget, 整理后再發(fā)上來

           

          看著網(wǎng)上鋪天蓋地的各種android應(yīng)用, 再看看我這個小破軟件, 實在有點拿不出手, 但既然做了就得不斷完善下去

          目標是做一個封裝widget的集合, 方便開發(fā)者使用

           

          1, 使用線程和handler message機制讀取文件列表, 提升軟件性能

          2, 解決文件列表多次滾動后速度下降的問題

          3, 打開文件使用手機關(guān)聯(lián)的應(yīng)用

          4, 增加文件縮略圖顯示

          --------------------------------------------------------10月27日更新0.2版 --------------------------------------------------------------------

          1.  0.2版主要增加了一些使用者的功能, 增加了收藏夾功能, 方便用戶快速的瀏覽到經(jīng)常訪問的文件或文件夾

          2.  修改了一些for developer的bug

           

           

          --------------------------------------------------------  0.1版 --------------------------------------------------------------------

           

             

           

           

           

           

          -------------------------------------------------------------------- for developer --------------------------------------------------------------------

          G1上并沒有隨系統(tǒng)附帶文件瀏覽軟件, 考慮到電子書,媒體播放器或其它一些軟件會使用到文件瀏覽,選擇文件或文件夾, 所以先做了這個文件管理工具并封裝一些參數(shù)供第三方程序調(diào)用,可以做為插件形式使用
          把文件管理器封裝起來并使用intent機制設(shè)置瀏覽參數(shù)和調(diào)用
          目前暫不支持多文件選擇, 將在下一版中發(fā)布
          調(diào)用程序示例

          1           Button button2  =  (Button) findViewById(R.id.but2);
          2           button2.setOnClickListener(testFileManager);

           

           1  private  OnClickListener testFileManager  =   new  OnClickListener() {
           2           public   void  onClick(View v) {
           3              Intent intent  =   new  Intent( " net.uiiang.android.alkaid.FILEMANAGER " );
           4              
           5               // 參數(shù)root_directory, 設(shè)置瀏覽的根目錄, 例如設(shè)置 /sdcard則只允許程序瀏覽sd卡中的內(nèi)容, 當程序回退上層文件夾到/sdcard后不再向上回退
           6               // 參數(shù)類型為字符串, 默認為"/"(根目錄)
           7              intent.putExtra( " root_directory " " / " );
           8              
           9               // 參數(shù)exclude_directory, 設(shè)置不顯示的目錄, 例如設(shè) 置"/data", "/dev", 則"/data", "/dev"這兩個目錄不會顯示給用戶
          10               // 參數(shù)類型為字符串數(shù)組, 默認不排除任何文件夾
          11              intent.putExtra( " exclude_directory " ,
          12                       new  String[] {  " /data " " /dev "  });
          13  
          14               // 參數(shù)thrid_party_call, 當?shù)谌匠绦蛘{(diào)用時, 必須設(shè)置 此參數(shù)為true, 否則下面幾個參數(shù)不起作用
          15               // 參數(shù)類型為boolean, 默認為false, 會顯示以下參數(shù)可設(shè)置的 所有菜單(除 選擇菜單)
          16              intent.putExtra( " thrid_party_call " true
          );
          17              
          18               //  參數(shù)directory_show_type, 目錄瀏覽方式
          19               //  參數(shù)類型為 int, 默認為0
          20               //  0 : 顯示文件和文件夾(默認)
          21               //  1 : 只顯示文件
          22               //  3 : 只顯示文件夾 
          23              intent.putExtra( " directory_show_type " 0 );
          24              
          25               // 參數(shù)use_menu_items, 設(shè)置顯示的預置菜單
          26               // 參數(shù)類型為:int數(shù)組
          27               // 菜單列表:
          28               //  1 : 上下文菜單-打開  (文件夾)
          29               //  2 : 上下文菜單-刪除
          30               //  3 : 上下文菜單-詳細信息
          31               //  4 : 上下文菜單-復制
          32               //  5 : option菜單-粘貼
          33               //  6 : option菜單-新建文件夾
          34               //  99: 上下文菜單-選擇 , 若需要文件管理器返回一個選中的文件路 徑, 則必須設(shè)置此菜單
          35               //  當用戶點擊此菜單后, 文件管理器退出并返回給調(diào)用程序一個字符串數(shù) 組, 數(shù)組中包含文件路徑信息
          36              intent.putExtra( " use_menu_items " new   int [] {  99  });
          37              
          38               //  參數(shù)show_info_in_list, 是否在瀏覽文件中顯示簡單的 信息, 如文件夾中包含多少子文件夾和文件
          39               //  默認為true
          40              intent.putExtra( " show_info_in_list " false );
          41              
          42               //  參數(shù)show_file_extension, 是否顯示文件后綴名
          43               //  默認為 true
          44              intent.putExtra( " show_file_extension " false );
          45              
          46               //  參數(shù)use_simple_view, 是否使用簡單文件預覽
          47               //  用戶單擊文件后可以簡單的預覽文件內(nèi)容, 目前支持圖片和音樂文件
          48               //  默認為 true
          49              intent.putExtra( " use_simple_view " false );
          50              
          51               //  參數(shù)animation_show_list, 是否使用動態(tài)效果顯示文 件列表, 目前只支持向下卷簾式的效果
          52               //  默認為true
          53              intent.putExtra( " animation_show_list " true );
          54              
          55               // 參數(shù)mutiple_select, 是否支持多選, 為true可以一次 性選擇多個文件或目錄
          56               // 默認為false
          57              intent.putExtra( " mutiple_select " , false );
          58  
          59              startActivityForResult(intent, SELECT_FILE);
          60          }
          61      };



          通過startActivityForResult調(diào)用文件管理器, 并使用上下文菜單選擇文件或文件夾

           

           

          點擊"選擇"后, 返回到調(diào)用程序

           1      @Override
           2       protected   void  onActivityResult( int  requestCode,  int  resultCode, Intent data) {
           3           super .onActivityResult(requestCode, resultCode, data);
           4           if  (requestCode  ==  SELECT_FILE) {
           5               if  (resultCode  ==  RESULT_OK) {
           6                   //  參數(shù)名為selected_uri, 得到字符串數(shù)組中包含文件路徑
           7                  String[] selectArr  =  data.getExtras().getStringArray(
           8                           " selected_uri " );
           9                   if  (selectArr  !=   null ) {
          10                      String selectFile  =   "" ;
          11                       for  (String string : selectArr) {
          12                          System.out.println( " you select  =  "
          13                                   +  data.getExtras().getStringArray(
          14                                           " selected_uri " ));
          15                      }
          16                  }
          17  
          18              }
          19          }
          20      }

           

          posted @ 2010-05-05 17:10 小強 閱讀(339) | 評論 (0)編輯 收藏
               摘要: 1. 0.2版主要增加了一些使用者的功能, 增加了收藏夾功能, 方便用戶快速的瀏覽到經(jīng)常訪問的文件或文件夾

          2. 修改了一些for developer的bug  閱讀全文
          posted @ 2009-10-27 16:05 小強 閱讀(1645) | 評論 (2)編輯 收藏
               摘要: 為文件將來做電子書或媒體播放器等程序時瀏覽文件
          把文件管理器封裝起來并使用intent機制設(shè)置瀏覽參數(shù)和調(diào)用  閱讀全文
          posted @ 2009-10-17 20:21 小強 閱讀(2670) | 評論 (2)編輯 收藏
               摘要: 練習作品 一個簡單的 android 文件管理器, 支持第三方程序調(diào)用  閱讀全文
          posted @ 2009-10-17 19:50 小強 閱讀(1934) | 評論 (1)編輯 收藏
               摘要: 為了體現(xiàn)出android強大的網(wǎng)絡(luò)功能 寫了一個小爬蟲程序, 通過網(wǎng)絡(luò)直接從網(wǎng)站上下載電子書  閱讀全文
          posted @ 2008-06-30 12:00 小強 閱讀(1381) | 評論 (0)編輯 收藏
               摘要: 晚上等著看歐洲杯,閑來無賴接著研究android , 更新了一下uReader  閱讀全文
          posted @ 2008-06-18 12:46 小強 閱讀(1530) | 評論 (4)編輯 收藏
               摘要: 閑來無事, 研究了一下android. 做一個小應(yīng)用練手.
            閱讀全文
          posted @ 2008-06-17 17:31 小強 閱讀(1890) | 評論 (4)編輯 收藏
               摘要:   閱讀全文
          posted @ 2008-06-10 17:34 小強 閱讀(413) | 評論 (0)編輯 收藏
               摘要: 刪除ANDROID數(shù)據(jù)庫  閱讀全文
          posted @ 2008-06-10 17:30 小強 閱讀(1909) | 評論 (0)編輯 收藏
               摘要: android 技巧一, 快速顯示修改結(jié)果  閱讀全文
          posted @ 2008-06-03 17:44 小強 閱讀(356) | 評論 (0)編輯 收藏
               摘要: device commands:
          adb update DATAOPTS - Flash the specified update file.
          If file is not passed, update.zip is used.
          adb push - copy file/dir to device
          adb pull - copy file/dir from device
          adb sync [ ] - copy host->device only if changed
          (see 'adb help all')
          adb shell - run remote shell interactively
            閱讀全文
          posted @ 2008-06-03 17:36 小強 閱讀(1051) | 評論 (0)編輯 收藏
               摘要: adb(Android Debug Bridge)是Android提供的一個通用的調(diào)試工具,借助這個工具,我們可以管理設(shè)備或手機模擬器的狀態(tài)。還可以進行以下的操作:

          1、快速更新設(shè)備或手機模擬器中的代碼,如應(yīng)用或Android系統(tǒng)升級;

          2、在設(shè)備上運行shell命令;

          3、管理設(shè)備或手機模擬器上的預定端口;

          4、在設(shè)備或手機模擬器上復制或粘貼文件;

            閱讀全文
          posted @ 2008-06-03 17:35 小強 閱讀(1504) | 評論 (0)編輯 收藏
               摘要: Android是基于Linux內(nèi)核的,對于喜歡研究底層的朋友來說,自然不會放過搞明白Linux層面上一些東西的機會。當然,最終目的還是要搞清楚Linux是如何和上層lib以及虛擬機結(jié)合的,但是這得等Google完全開源Android之后了。很多關(guān)于Linux運行的細節(jié),都可以通過adb的shell來看到。  閱讀全文
          posted @ 2008-06-03 17:30 小強 閱讀(3581) | 評論 (1)編輯 收藏
          主站蜘蛛池模板: 四平市| 永嘉县| 安阳县| 宁陕县| 柳林县| 遂昌县| 班戈县| 扶绥县| 周至县| 云南省| 津市市| 滨州市| 安图县| 仲巴县| 昌邑市| 华阴市| 双桥区| 巴彦淖尔市| 兰溪市| 建水县| 杭州市| 钦州市| 明星| 安庆市| 宜阳县| 慈利县| 兴宁市| 尉犁县| 陇川县| 车致| 泾川县| 商洛市| 奎屯市| 洱源县| 曲水县| 蓬溪县| 湖州市| 宜君县| 鹿邑县| 乌拉特后旗| 襄垣县|