亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Android中如何實現一個簡易時間軸

發布時間:2022-04-08 16:08:10 來源:億速云 閱讀:309 作者:iii 欄目:編程語言

這篇文章主要講解了“Android中如何實現一個簡易時間軸”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“Android中如何實現一個簡易時間軸”吧!

1.新建一個自定義控件:

public class WorkExcView extends LinearLayout {
private TextView dataLeft;
private TextView dataRight;
private TextView company;
private TextView job;
private TextView jobAsses;
private TextView xiTong;
private TextView ziTian;
private LinearLayout jobContentContainer;
private TextView jobContent;
private LinearLayout commentContainer;
private LinearLayout nianContentContainer;
private TextView nianContent;
private LinearLayout base;
private LinearLayout yueXingContainer;
private TextView yueContent;
private LinearLayout nianXingContainer;
private TextView yueMoreContent;
private TextView nianMoreContent;
private String company_id;

public WorkExcView(Context context) {
  this(context,null);
}

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

private void init() {
  View inflate = View.inflate(getContext(), R.layout.activity_four_workexcview, this);
  dataLeft = (TextView) inflate.findViewById(R.id.workexcview_data_left);
  dataRight= (TextView) inflate.findViewById(R.id.workexcview_data_right);
  company = (TextView) inflate.findViewById(R.id.workexcview_company);
  job = (TextView) inflate.findViewById(R.id.workexcview_job);
  jobAsses = (TextView) inflate.findViewById(R.id.workexcview__job_asses);
  xiTong = (TextView) inflate.findViewById(R.id.workexcview_xitong);
  ziTian = (TextView) inflate.findViewById(R.id.workexcview_zitian);
  jobContent = (TextView) inflate.findViewById(R.id.workexcview_jobcontent);
  nianContent = (TextView) inflate.findViewById(R.id.workexcview_niancontent);
  jobContentContainer = (LinearLayout)inflate.findViewById(R.id.workexcview_jobcontent_container);
  commentContainer = (LinearLayout)inflate.findViewById(R.id.workexcview__comment_container);
  nianContentContainer= (LinearLayout)inflate.findViewById(R.id.workexcview__niancontent_container);
  base = (LinearLayout)inflate.findViewById(R.id.workexcview__base);
  yueXingContainer = (LinearLayout)inflate.findViewById(R.id.workexcview_yuexing_container);
  yueContent = (TextView)inflate.findViewById(R.id.workexcview_yuecontent);
  nianXingContainer = (LinearLayout)inflate.findViewById(R.id.workexcview_nianxing_container);
  yueMoreContent = (TextView)inflate.findViewById(R.id.workexcview_yuecontentmore);
  nianMoreContent = (TextView)inflate.findViewById(R.id.workexcview_niancontentmore);
}

public void initData(final FourBean.JobsBean jobsBean) {
   //賦值代碼
}

XML文件:

<?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:orientation="vertical"
android:id="@+id/workexcview__base"
android:paddingLeft="8dp">

<RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content">

  <ImageView
    android:id="@+id/workexcview_landian"
    android:layout_width="15dp"
    android:layout_height="15dp"
    android:layout_centerVertical="true"
    android:src="@mipmap/landian" />

  <TextView
    android:id="@+id/workexcview_data_left"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginLeft="3dp"
    android:layout_toRightOf="@+id/workexcview_landian"
    android:text="2016.03"
    android:textColor="@color/text"
    android:textSize="15sp" />

  <TextView
    android:id="@+id/workexcview__data_zhong"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/workexcview_data_left"
    android:text=" —— "
    android:textColor="@color/text" />

  <TextView
    android:id="@+id/workexcview_data_right"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/workexcview__data_zhong"
    android:text="2016.03"
    android:textColor="@color/text"
    android:textSize="15sp" />

  <TextView
    android:id="@+id/workexcview_zitian"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:background="@drawable/four_select"
    android:padding="4dp"
    android:paddingRight="6dp"
    android:text="自填"
    android:textColor="@color/red"
    android:textSize="12sp"
    android:visibility="gone" />


  <!--    <ImageView
        android:id="@+id/workexcview_xitong"
        android:layout_width="40dp"
        android:layout_height="20dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:paddingRight="10dp"
        android:src="@mipmap/xitong"
        android:visibility="gone" />-->
  <TextView
    android:id="@+id/workexcview_xitong"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:background="@drawable/textview_shape"
    android:padding="4dp"
    android:paddingRight="6dp"
    android:text="系統"
    android:textColor="@color/holo_blue_light"
    android:textSize="12sp"
    android:visibility="gone" />

  <RelativeLayout
    android:id="@+id/four_setting_workexc_container"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:visibility="gone">

    <TextView
      android:id="@+id/four_setting_workexc_logo"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_centerVertical="true"
      android:text="編輯"
      android:textColor="@android:color/holo_blue_light"
      android:textSize="16sp" />

    <ImageView
      android:layout_width="20dp"
      android:layout_height="20dp"
      android:layout_centerVertical="true"
      android:layout_toLeftOf="@+id/four_setting_workexc_logo"
      android:src="@drawable/xierijidianji3x" />
  </RelativeLayout>
</RelativeLayout>

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

  <RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent">

    <TextView
      android:layout_width="1dp"
      android:layout_height="match_parent"
      android:layout_marginLeft="7dp"
      android:background="@color/black" />

  </RelativeLayout>

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

    <RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="8dp">

      <TextView
        android:id="@+id/workexcview_company"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:text="某某公司"
        android:textColor="@color/text"
        android:textSize="14sp" />

      <TextView
        android:id="@+id/workexcview_company_zhong"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/workexcview_company"
        android:text=" / "
        android:textColor="@color/text"
        android:textSize="14sp" />

      <TextView
        android:id="@+id/workexcview_job"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/workexcview_company_zhong"
        android:text="web前段工程師"
        android:textColor="@color/text"
        android:textSize="14sp" />

    </RelativeLayout>

    <LinearLayout
      android:id="@+id/workexcview_jobcontent_container"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="5dp"
      android:orientation="vertical"
      android:padding="8dp">

      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="工作描述:"
        android:textColor="@color/text" />

      <TextView
        android:id="@+id/workexcview_jobcontent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:text="巴拉巴拉" />

    </LinearLayout>
    <LinearLayout
      android:id="@+id/workexcview__yuecontent_container"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="5dp"
      android:orientation="vertical"
      android:padding="8dp"
      android:visibility="visible">

      <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
          android:id="@+id/workexcview_yuecontent_logo"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerVertical="true"
          android:text="最新月評價:"
          android:textColor="@color/text" />
        <LinearLayout
          android:layout_centerVertical="true"
          android:id="@+id/workexcview_yuexing_container"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          android:layout_toRightOf="@+id/workexcview_yuecontent_logo"
          >

        </LinearLayout>
        <TextView
          android:layout_alignParentRight="true"
          android:id="@+id/workexcview_yuecontentmore"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="3dp"
          android:gravity="center"
          android:padding="2dp"
          android:layout_centerVertical="true"
          android:background="@drawable/textview_shape"
          android:text="更多"
          android:textColor="@color/blue_title" />
      </RelativeLayout>


      <TextView
        android:id="@+id/workexcview_yuecontent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:text="無"
        android:textColor="@color/gray" />


    </LinearLayout>
    <LinearLayout
      android:id="@+id/workexcview__niancontent_container"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="5dp"
      android:orientation="vertical"
      android:padding="8dp"
      android:visibility="visible">

      <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
          android:id="@+id/workexcview_niancontent_logo"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerVertical="true"
          android:text="最新年評價:"
          android:textColor="@color/text" />
        <LinearLayout
          android:layout_centerVertical="true"
          android:id="@+id/workexcview_nianxing_container"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          android:layout_toRightOf="@id/workexcview_niancontent_logo"
          >

        </LinearLayout>
        <TextView
          android:id="@+id/workexcview_niancontentmore"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="3dp"
          android:padding="2dp"
          android:layout_centerVertical="true"
          android:background="@drawable/textview_shape"
          android:text="更多"
          android:layout_alignParentRight="true"
          android:textColor="@color/blue_title" />
      </RelativeLayout>


      <TextView
        android:id="@+id/workexcview_niancontent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:text="無"
        android:textColor="@color/gray" />


    </LinearLayout>

    <LinearLayout
      android:id="@+id/workexcview__comment_container"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="5dp"

      android:orientation="vertical"
      android:padding="8dp"
      android:visibility="visible">

      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="離職評價:"
        android:textColor="@color/text" />

      <TextView
        android:id="@+id/workexcview__job_asses"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:text=""
        android:textColor="@color/gray" />
    </LinearLayout>


  </LinearLayout>
 </LinearLayout>
</LinearLayout>

2.使用方式:其實很簡單,直接for循環new出來賦值就行啦,因為本身就是一個自定義控件~

  fourWorkexcContainer.removeAllViews();
  for (int i = 0; i < jobs.size(); i++) {
    FourBean.JobsBean jobsBean = jobs.get(i);
    WorkExcView workExcView = new WorkExcView(getContext());
    workExcView.initData(jobsBean);
    fourWorkexcContainer.addView(workExcView);
  }

感謝各位的閱讀,以上就是“Android中如何實現一個簡易時間軸”的內容了,經過本文的學習后,相信大家對Android中如何實現一個簡易時間軸這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

唐海县| 甘南县| 杭锦后旗| 留坝县| 科尔| 吴堡县| 萨嘎县| 栾川县| 焦作市| 佳木斯市| 库尔勒市| 长兴县| 永川市| 吴桥县| 永康市| 万源市| 平安县| 黄山市| 合川市| 白朗县| 聂拉木县| 博乐市| 大丰市| 瑞安市| 商河县| 绥宁县| 泰和县| 嘉兴市| 关岭| 九寨沟县| 平度市| 尚志市| 定西市| 象州县| 鞍山市| 宜州市| 朝阳区| 桐梓县| 娄烦县| 阳东县| 镇远县|