<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      ListView中動態(tài)顯示和隱藏Header&Footer

      如果需要?jiǎng)討B(tài)的顯示和隱藏footer的話,按照慣例,誤以為直接通過setVisibility中的View.GONE就可以實(shí)現(xiàn)。但是在實(shí)際使用中發(fā)現(xiàn)并不是這樣的。

      例如,先加載footer布局:

      private View mFooter;
      
      mFooter = LayoutInflater.from(this).inflate(R.layout.footer, null);  //加載footer的布局
      mListView.addFooterView(mFooter);
      

      如果想動態(tài)隱藏這個(gè)footer,慣性思維是直接設(shè)置footer為gone:(其實(shí)這樣做是不對的)

      mFooter.setVisibility(View.GONE);  //隱藏footer

      實(shí)際上,直接設(shè)置GONE后,雖然元素是隱藏了,但是還是占用著那個(gè)區(qū)域,此時(shí)和View.INVISIBILE效果一樣。

      footer的正確使用方法如下:

      1、方法一:

      (1)布局文件:在footer布局文件的最外層再套一層LinearLayout/RelativeLayout,我們稱為footerParent。

      layout_footer_listview.xml:(完整版代碼)

      <?xml version="1.0" encoding="utf-8"?>
      
      <LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/mFooterparent"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="#FFFFFF"
          android:gravity="center"
          android:orientation="vertical"
          >
      
          <LinearLayout
              android:id="@+id/mFooter"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:gravity="center">
      
              <TextView
                  android:layout_width="wrap_content"
                  android:layout_height="40dp"
                  android:layout_centerVertical="true"
                  android:layout_marginLeft="10dp"
                  android:gravity="center"
                  android:text="查看更多"
                  android:textColor="#ff0000"
                  android:textSize="20sp"/>
          </LinearLayout>
      </LinearLayout>
      

      (2)加載footer和footerParent的布局:

      private View mFooter; //footer
      private View mFooterParent;  //footer的最外面再套一層LinearLayout
      
      mFooterParent = LayoutInflater.from(getActivity()).inflate(R.layout.footerparent_listview, null);//加載footerParent布局
      mFooter = mFooterParent.findViewById(R.id.footer);
      listView.addFooterView(mFooterParent);  //把footerParent放到ListView當(dāng)中
      
      mFooterParent.setOnClickListener(MainActivity.this); //綁定監(jiān)聽事件,點(diǎn)擊查看全部列表

      (3)設(shè)置footer為gone:(不是設(shè)置footerParent為gone)

      mFooter.setVisibility(View.GONE);

       

      2、方法二:或者直接在代碼中為footer添加footerParent也可以,如下:

      private View mFooter; //footer
      mFooter = LayoutInflater.from(getActivity()).inflate(R.layout.footer_listview, null);//加載footer布局
      
      LinearLayout mFooterParent = new LinearLayout(context);  
      mFooterParent.addView(mFooter);//在footer的最外面再套一層LinearLayout(即footerParent)
      listView.addFooterView(mFooterParent);//把footerParent放到ListView當(dāng)中
      

      當(dāng)需要隱藏footer的時(shí)候,設(shè)置footer為gone:(不是設(shè)置footerParent為gone)

      mFooter.setVisibility(View.GONE);
      posted @ 2019-08-12 01:25  ganzhijie  閱讀(286)  評論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 97人妻精品一区二区三区| 国产精品国产亚洲区久久| 狠狠色噜噜狠狠亚洲AV| 91福利一区福利二区| 国产真人无遮挡免费视频| 男女啪啪高潮激烈免费版| 精品无码人妻| 亚洲中文字幕国产综合| 天天躁夜夜躁狠狠综合| 自拍偷自拍亚洲精品播放 | 国产中文字幕精品在线| 99在线小视频| 国产成人免费一区二区三区| 99久久国产成人免费网站| 亚洲一区二区av在线| 国产无遮挡又黄又爽又色| 成在人线av无码免费看网站直播| 当雄县| 我要看亚洲黄色太黄一级黄| 女同另类激情在线三区| 中文无码av一区二区三区| 华蓥市| а∨天堂一区中文字幕| 最近最好的2019中文| 高中女无套中出17p| 成人午夜福利一区二区四区| 欧美国产精品啪啪| 国产精品免费中文字幕| 国产高清乱码又大又圆| 亚洲日韩图片专区第1页| 亚洲精品日韩在线观看| 精品国产一区二区三区国产区| 亚洲欧美日韩精品久久亚洲区色播| 日本一道一区二区视频| 五月开心六月丁香综合色啪| 久久av色欲av久久蜜桃网| 亚洲精品区二区三区蜜桃| 国产卡一卡二卡三免费入口| 柳林县| 中国性欧美videofree精品| 国产三级视频网站|