最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android GridView簡(jiǎn)單實(shí)例

 更新時(shí)間:2017年01月25日 09:56:46   作者:stevefat  
這篇文章主要為大家詳細(xì)介紹了Android GridView簡(jiǎn)單實(shí)例,簡(jiǎn)單實(shí)現(xiàn)九宮格效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

也是今天用到的一個(gè)東西,就是簡(jiǎn)單實(shí)現(xiàn)九宮格的Demo

1.就是定義各種layout 和對(duì)應(yīng)的item

我的:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#fff"
  android:orientation="vertical" >

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <GridView 
      android:id="@+id/gridView"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:numColumns="3"
      android:background="#fff"></GridView>


  </LinearLayout>

</LinearLayout>

itme的

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:padding="10dp"
  android:layout_gravity="center"
  android:background="#fff"
  android:orientation="vertical" >

  <ImageView
    android:id="@+id/iv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

  <TextView
    android:id="@+id/tv"
    android:paddingTop="10dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#000"
    android:text="管線" />

</LinearLayout>

開始準(zhǔn)備數(shù)據(jù):

  /**
   * 準(zhǔn)備顯示的數(shù)據(jù)
   */
  public void initData() {
    // 生成動(dòng)態(tài)數(shù)組,并且轉(zhuǎn)入數(shù)據(jù) ,暫時(shí)就這樣來(lái)處理
    lstImageItem = new ArrayList<HashMap<String, Object>>();
    for (int i = 0; i < 3; i++) {
      HashMap<String, Object> map = new HashMap<String, Object>();
      map.put("ItemImage", R.drawable.osg);// 添加圖像資源的ID
      map.put("ItemText", "各種管線" + String.valueOf(i));// 按序號(hào)做ItemText
      lstImageItem.add(map);
    }
  }

設(shè)置顯示

gv = (GridView) view.findViewById(R.id.gridView);
    SimpleAdapter adapter = new SimpleAdapter(this, lstImageItem, R.layout.gridview_item, new String[] { "ItemImage", "ItemText" },
        new int[] { R.id.iv, R.id.tv });
gv.setAdapter(adapter);

最后扔一張效果圖

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android實(shí)現(xiàn)圓形圖片或者圓角圖片

    Android實(shí)現(xiàn)圓形圖片或者圓角圖片

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)圓形圖片或者圓角圖片的代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-06-06
  • 讀取android根目錄下的文件或文件夾實(shí)例

    讀取android根目錄下的文件或文件夾實(shí)例

    本篇文章主要介紹了讀取android根目錄下的文件或文件夾,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2016-12-12
  • Android activity堆棧及管理實(shí)例詳解

    Android activity堆棧及管理實(shí)例詳解

    這篇文章主要介紹了Android activity堆棧及管理實(shí)例詳解的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,對(duì)android activity堆棧相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧
    2016-09-09
  • Android中給fragment寫入?yún)?shù)的輕量開發(fā)包FragmentArgs簡(jiǎn)介

    Android中給fragment寫入?yún)?shù)的輕量開發(fā)包FragmentArgs簡(jiǎn)介

    這篇文章主要介紹了Android中給fragment寫入?yún)?shù)的輕量開發(fā)包FragmentArgs簡(jiǎn)介,需要的朋友可以參考下
    2014-10-10
  • Android Activity被回收的情況分析

    Android Activity被回收的情況分析

    Activity作為Android四大組件之一,他的啟動(dòng)絕對(duì)沒(méi)有那么簡(jiǎn)單。這里涉及到了系統(tǒng)服務(wù)進(jìn)程,啟動(dòng)過(guò)程細(xì)節(jié)很多,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值
    2022-11-11
  • Android錄音應(yīng)用實(shí)例教程

    Android錄音應(yīng)用實(shí)例教程

    這篇文章主要介紹了Android錄音應(yīng)用實(shí)例,是Android應(yīng)用程序開發(fā)中非常重要的一個(gè)功能,需要的朋友可以參考下
    2014-09-09
  • Android開發(fā)之AppWidget詳解

    Android開發(fā)之AppWidget詳解

    這篇文章主要介紹了Android開發(fā)之AppWidget詳解,想了解桌面程序AppWidget的同學(xué)可以參考下
    2021-04-04
  • Android實(shí)現(xiàn)Service在前臺(tái)運(yùn)行服務(wù)

    Android實(shí)現(xiàn)Service在前臺(tái)運(yùn)行服務(wù)

    這篇文章主要為大家詳細(xì)介紹了Android中實(shí)現(xiàn)Service在前臺(tái)運(yùn)行服務(wù),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • Android實(shí)現(xiàn)左右滑動(dòng)切換圖片

    Android實(shí)現(xiàn)左右滑動(dòng)切換圖片

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)左右滑動(dòng)切換圖片,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • 使用RoundedBitmapDrawable生成圓角圖片的方法

    使用RoundedBitmapDrawable生成圓角圖片的方法

    由于RoundedBitmapDrawable類沒(méi)有直接提供生成圓形圖片的方法,所以生成圓形圖片首先需要對(duì)原始圖片進(jìn)行裁剪,將圖片裁剪成正方形,最后再生成圓形圖片,具體實(shí)現(xiàn)方法,可以參考下本文
    2016-09-09

最新評(píng)論

萍乡市| 阿勒泰市| 湟源县| 滁州市| 新民市| 礼泉县| 略阳县| 祁阳县| 兴化市| 疏附县| 武汉市| 苏尼特右旗| 濮阳县| 晋城| 麟游县| 姚安县| 阆中市| 肥西县| 鄂托克前旗| 同心县| 隆德县| 庄河市| 沾化县| 松溪县| 木里| 潜江市| 平泉县| 南陵县| 沙洋县| 安吉县| 泾源县| 旅游| 乐清市| 临沭县| 化州市| 皮山县| 通化县| 灯塔市| 泽库县| 民丰县| 天等县|