posts - 189,comments - 115,trackbacks - 0

          Android控件學(xué)習(xí)之——Gallery控件

          http://student.csdn.net/space.php?uid=46868&do=blog&id=18805

          Android體驗(yàn)系列之--Gallery控件

          以下列子是參考 Android官方的DEV網(wǎng)站(由于Android官方的DEV網(wǎng)站在國(guó)內(nèi)基本訪問(wèn)不了(我是都訪問(wèn)不了 只能用代理)所以就貼在這里提供給國(guó)內(nèi)初學(xué)者們)

          Gallery:即圖片瀏覽控件

          layout部分:

          <Gallery xmlns:android="http://schemas.android.com/apk/res/android
              android:id="@+id/gallery"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"/>

          代碼部分:

          主類部分代碼:

                  Gallery g = (Gallery) findViewById(R.id.gallery);//定義 Gallery 控件
                  g.setAdapter(new ImageAdapter(this));//設(shè)置 Gallery 控件的圖片源

                  g.setOnItemClickListener(new OnItemClickListener() { //點(diǎn)擊監(jiān)聽(tīng)事件
                      public void onItemClick(AdapterView parent, View v, int position, long id) {//點(diǎn)擊事件
                          Toast.makeText(galleryMain.this, "" + position, Toast.LENGTH_SHORT).show(); //Toast顯示圖片位置
                      }
                  });

          ImageAdapter 類

              private Context mContext; //定義Context

              private Integer[] mImageIds = { //定義整型數(shù)組 即圖片源
                      R.drawable.sample_1,
                      R.drawable.sample_2,
                      R.drawable.sample_3,
                      R.drawable.sample_4,
                      R.drawable.sample_5,
                      R.drawable.sample_6,
                      R.drawable.sample_7
              };

              public ImageAdapter(Context c) { //聲明 ImageAdapter
                  mContext = c;
              }

              public int getCount() { //獲取圖片的個(gè)數(shù)
                  return mImageIds.length;
              }

              public Object getItem(int position) {//獲取圖片在庫(kù)中的位置
                  return position;
              }

              public long getItemId(int position) {//獲取圖片在庫(kù)中的位置
                  return position;
              }

              public View getView(int position, View convertView, ViewGroup parent) {
                  ImageView i = new ImageView(mContext);

                  i.setImageResource(mImageIds[position]);//給ImageView設(shè)置資源
                  i.setLayoutParams(new Gallery.LayoutParams(200, 200));//設(shè)置布局 圖片200×200顯示
                  i.setScaleType(ImageView.ScaleType.FIT_XY);//設(shè)置比例類型

                  return i;
              }

          Ok 運(yùn)行查看結(jié)果:



          android學(xué)習(xí)的網(wǎng)址

          android 學(xué)習(xí) http://www.moandroid.com

          javaeve 論壇 http://www.javaeye.com/forums/tag/Android

          臺(tái)灣 鞋柜 需翻墻http://walkingice.twbbs.org/blog/?p=922

          源碼修改 網(wǎng)站 http://gitorious.org/0xdroid/ 

          源碼 分析 http://android.git.kernel.org/

          goandroid的博客 http://blog.chinaunix.net/u2/85805/

          http://www.eoeandroid.com

          最近在把公司幾個(gè)同事帶動(dòng)起來(lái)和我一塊學(xué)android,由于本人比他們學(xué)的早就把一些資料整理出來(lái)了,現(xiàn)把常使用的android網(wǎng)址整理出來(lái)

          官網(wǎng):http://www.android.com/

          http://www.javaeye.com/topic/342006  這個(gè)人是牛人,有不少好文

          http://blog.chinaunix.net/u/20947/article_109523.html  這個(gè)寫的是比較偏底層的:希望龍堅(jiān)喜歡,哈哈

          http://dev.mmarket.com/cmdn/supesite/  中國(guó)移動(dòng)開(kāi)發(fā)者網(wǎng)址

          http://stackoverflow.com/questions/631238/modifying-the-android-seekbar-widget-to-operate-vertically  這個(gè)是國(guó)外的網(wǎng)址

          http://androidos.cc/dev/  這個(gè)還行,不過(guò)我不常去

          http://www.eoeandroid.com/forumdisplay.php?fid=27 這個(gè)是我常去的論壇,我的ID是xusaomaiss,里面有我的帖

          //可以加一些QQ群,里面挺多牛人的,注:這年頭好像牛人不常說(shuō)話,寫代碼去了。

          //超好的國(guó)外網(wǎng)址,英文超簡(jiǎn)單,分類十分清楚
          http://www.anddev.org/android_weather_forecast_-_google_weather_api_-_full_source-t361.html


          posted on 2010-08-26 20:07 MEYE 閱讀(1813) 評(píng)論(0)  編輯  收藏 所屬分類: Android3D
          主站蜘蛛池模板: 武冈市| 牡丹江市| 孝感市| 沙雅县| 平南县| 定南县| 鞍山市| 龙门县| 陕西省| 潞城市| 无极县| 洪洞县| 沙田区| 西乌珠穆沁旗| 东港市| 鄯善县| 犍为县| 昌乐县| 乡宁县| 仪陇县| 阳城县| 维西| 米易县| 如皋市| 清水县| 宁远县| 绥滨县| 勐海县| 调兵山市| 丁青县| 南昌市| 卓尼县| 通榆县| 卫辉市| 乐至县| 四川省| 迭部县| 永登县| 金塔县| SHOW| 灯塔市|