99偷拍视频精品区一区二,口述久久久久久久久久久久,国产精品夫妇激情啪发布,成人永久免费网站在线观看,国产精品高清免费在线,青青草在线观看视频观看,久久久久久国产一区,天天婷婷久久18禁,日韩动漫av在线播放直播

Android中如何使用TagFlowLayout制作動(dòng)態(tài)添加刪除標(biāo)簽-創(chuàng)新互聯(lián)

這篇文章給大家分享的是有關(guān)Android中如何使用TagFlowLayout制作動(dòng)態(tài)添加刪除標(biāo)簽的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

創(chuàng)新互聯(lián)是一家專(zhuān)注于成都做網(wǎng)站、網(wǎng)站制作與策劃設(shè)計(jì),鞏義網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專(zhuān)注于網(wǎng)站建設(shè)十余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專(zhuān)業(yè)建站公司;建站業(yè)務(wù)涵蓋:鞏義等地區(qū)。鞏義做網(wǎng)站價(jià)格咨詢(xún):028-86922220

效果圖

Android中如何使用TagFlowLayout制作動(dòng)態(tài)添加刪除標(biāo)簽

簡(jiǎn)單的效果圖(使用開(kāi)源庫(kù))[FlowLayout](“ https://github.com/hongyangAndroid/FlowLayout “)

步驟

導(dǎo)包

compile 'com.zhy:flowlayout-lib:1.0.3'
<com.zhy.view.flowlayout.TagFlowLayout
  android:id="@+id/id_flowlayout"
  zhy:max_select="-1"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:padding="20dp">
</com.zhy.view.flowlayout.TagFlowLayout>

初始化數(shù)據(jù)

private String[] mVals = new String[]
    {"Hello", "Android", "Weclome Hi ", "Button", "TextView", "Hello",
        "Android", "Weclome", "Button ImageView", "TextView", "Helloworld" };
 arrTab = new ArrayList();
  //添加一條數(shù)據(jù)用于添加標(biāo)簽的替換
  arrTab.add("tab");

設(shè)置TagFlowLayout的adapter

//設(shè)置adapter
  adapter = new TagAdapter<String>(arrTab){
    @Override
    public View getView(FlowLayout parent, final int position, String s) {
      System.out.println(position + "---" + (arrTab.size() - 1));
      if (position == arrTab.size() - 1){
        //設(shè)置最后一個(gè)添加標(biāo)簽的布局
        LinearLayout iv = (LinearLayout) LayoutInflater.from(SecondActivity.this).inflate( R.layout.iv,
            mFlowLayout,false);
        //如果點(diǎn)擊就添加元素并刷新adapter
        iv.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            int i = arrTab.size() - 1;
            //將新加入的數(shù)據(jù)加到集合的最后一個(gè)位置,而原來(lái)的添加圖標(biāo)會(huì)到 +1 的位置 
            arrTab.add(i , mVals[position]);
            adapter.notifyDataChanged();
          }
        });
        return iv ;
      }else{
      //正常標(biāo)簽的布局
        RelativeLayout tv = (RelativeLayout) LayoutInflater.from(SecondActivity.this).inflate( R.layout.tv,
            mFlowLayout,false);
        TextView viewById = (TextView) tv.findViewById(R.id.tv_name);
        viewById.setText(s);
        ImageView imageView = (ImageView) tv.findViewById(R.id.iv_delete);
        imageView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            arrTab.remove(position);
            System.out.println("我點(diǎn)擊的是" + position);
            adapter.notifyDataChanged();
          }
        });
        return tv;
      }
    }
  };
  mFlowLayout.setAdapter(adapter);

各種布局文件

iv
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="88dp"
android:paddingTop="5dp"
android:layout_height="40dp">
<ImageView
  android:layout_gravity="center"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:background="@drawable/bacs_btn_addbq"
  />
  </LinearLayout>
tv
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="88dp"
android:layout_height="wrap_content">
<!--android:background="@drawable/tag_bg"-->
<TextView
  android:id="@+id/tv_name"
  android:layout_marginTop="7dp"
   android:layout_width="80dp"
  android:gravity="center"
   android:layout_height="32dp"
  android:background="@drawable/bg_tv"
   android:text="我是唯愛(ài)"
  android:textSize="13sp"
   android:textColor="#FFF">
</TextView>
<ImageView
  android:id="@+id/iv_delete"
  android:layout_alignParentRight="true"
  android:layout_width="15dp"
  android:layout_height="15dp"
  android:src="@drawable/sm_ico_sounddel"
  />
</RelativeLayout>

感謝各位的閱讀!關(guān)于“Android中如何使用TagFlowLayout制作動(dòng)態(tài)添加刪除標(biāo)簽”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

網(wǎng)頁(yè)題目:Android中如何使用TagFlowLayout制作動(dòng)態(tài)添加刪除標(biāo)簽-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)鏈接:http://www.yijiale78.com/article8/jjeop.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站響應(yīng)式網(wǎng)站品牌網(wǎng)站建設(shè)云服務(wù)器企業(yè)建站網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

微信小程序開(kāi)發(fā)