欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android多行標(biāo)簽熱點(diǎn)示例

 更新時(shí)間:2014年04月23日 09:00:57   作者:  
這篇文章主要介紹了android多行標(biāo)簽熱點(diǎn)示例,需要的朋友可以參考下

復(fù)制代碼 代碼如下:

package com.test.mytest.widget;

import java.util.List;

import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MutipleLabelLayout extends LinearLayout {

 public MutipleLabelLayout(Context context, AttributeSet attrs) {
  super(context, attrs);
 }

 public MutipleLabelLayout(Context context) {
  super(context);
 }

 public MutipleLabelLayout(Context context, List<String> list) {
  super(context);
  mList = list;
  mContext = context;
 }

 @Override
 protected void onAttachedToWindow() {
  super.onAttachedToWindow();
  new Handler().postDelayed(new Runnable() {

   @Override
   public void run() {
    init();
   }
  }, 500);
 }

 private void init() {
  this.setOrientation(LinearLayout.VERTICAL);
  LinearLayout row = new LinearLayout(mContext);
  row.setOrientation(LinearLayout.HORIZONTAL);
  this.addView(row);
  int rowWidth = this.getMeasuredWidth();
  int viewSumWidth = 0;
  for (String label : mList) {
   TextView labelView = new TextView(mContext);
   labelView.setText(label);
   labelView.setPadding(10, 0, 10, 0);
   labelView.setLayoutParams(new LayoutParams(
     LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
   row.addView(labelView);
   labelView.measure(0, 0);
   viewSumWidth += labelView.getMeasuredWidth();
   if (viewSumWidth > rowWidth) {
    row.removeView(labelView);
    row = new LinearLayout(mContext);
    row.setOrientation(LinearLayout.HORIZONTAL);
    this.addView(row);
    row.addView(labelView);
    labelView.measure(0, 0);
    viewSumWidth = labelView.getMeasuredWidth();
   }
   // System.out.println("viewSumWidth: " + viewSumWidth);
   // System.out.println("rowWidth: " + rowWidth);
  }
 }

 private List<String> mList;
 private Context mContext;

}

相關(guān)文章

  • Android實(shí)現(xiàn)靜默拍照功能

    Android實(shí)現(xiàn)靜默拍照功能

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)靜默拍照,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-06-06
  • Android搶紅包助手開發(fā)全攻略

    Android搶紅包助手開發(fā)全攻略

    這篇文章主要為大家詳細(xì)介紹了Android搶紅包助手開發(fā)全攻略,感興趣的小伙伴們可以參考一下
    2016-07-07
  • Android編程獲取網(wǎng)絡(luò)時(shí)間實(shí)例分析

    Android編程獲取網(wǎng)絡(luò)時(shí)間實(shí)例分析

    這篇文章主要介紹了Android編程獲取網(wǎng)絡(luò)時(shí)間,結(jié)合實(shí)例形式對(duì)比分析了Android通過訪問網(wǎng)絡(luò)及通過GPS獲取網(wǎng)絡(luò)時(shí)間的具體步驟與實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2016-01-01
  • Android串口開發(fā)之使用JNI實(shí)現(xiàn)ANDROID和串口通信詳解

    Android串口開發(fā)之使用JNI實(shí)現(xiàn)ANDROID和串口通信詳解

    這篇文章主要給大家介紹了關(guān)于Android串口開發(fā)之使用JNI實(shí)現(xiàn)ANDROID和串口通信的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-01-01
  • Android顯式Intent與隱式Intent的使用詳解

    Android顯式Intent與隱式Intent的使用詳解

    Intent的中文意思是“意圖,意向”, Intent對(duì)Android的核心和靈魂,是各組件之間的橋梁。四大組件分別為Activity 、Service、BroadcastReceiver、ContentProvider。而這四種組件是獨(dú)立的,它們之間可以互相調(diào)用,協(xié)調(diào)工作,最終組成一個(gè)真正的Android應(yīng)用
    2022-09-09
  • Android 7.0系統(tǒng)webview 顯示https頁面空白處理方法

    Android 7.0系統(tǒng)webview 顯示https頁面空白處理方法

    今天小編就為大家分享一篇Android 7.0系統(tǒng)webview 顯示https頁面空白處理方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-07-07
  • Android 實(shí)現(xiàn)切圓圖作為頭像使用實(shí)例

    Android 實(shí)現(xiàn)切圓圖作為頭像使用實(shí)例

    這篇文章主要介紹了Android 實(shí)現(xiàn)切圓圖作為頭像使用實(shí)例的相關(guān)資料,需要的朋友可以參考下
    2016-12-12
  • Android使用Canvas繪制圓形進(jìn)度條效果

    Android使用Canvas繪制圓形進(jìn)度條效果

    這篇文章主要為大家詳細(xì)介紹了Android使用Canvas繪制圓形進(jìn)度條效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • Android getevent用法實(shí)例詳解

    Android getevent用法實(shí)例詳解

    這篇文章主要介紹了Android getevent用法實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • Android獲取當(dāng)前應(yīng)用分配的最大內(nèi)存和目前使用內(nèi)存的方法

    Android獲取當(dāng)前應(yīng)用分配的最大內(nèi)存和目前使用內(nèi)存的方法

    今天小編就為大家分享一篇關(guān)于Android獲取當(dāng)前應(yīng)用分配的最大內(nèi)存和目前使用內(nèi)存的方法,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2019-02-02

最新評(píng)論