Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize a simple Timeline in Android

Shulou Source: shulou.com Published: 2022-06-01 00:17:28 10月01日 Update

This article mainly explains "how to implement a simple Timeline in Android," the explanation content in the article is simple and clear, easy to learn and understand, please follow the idea of small editor slowly in-depth, together to study and learn "how to implement a simple Timeline in Android" bar!

1. Create a new custom control:

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) { //assignment code}

XML file:

2. How to use: In fact, it is very simple, directly for the loop new out of the assignment on the line, because it is a custom control ~

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); } Thank you for your reading. The above is the content of "How to implement a simple Timeline in Android." After studying this article, I believe everyone has a deeper understanding of how to implement a simple Timeline in Android. The specific use situation still needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Tags: Time simplicity learning content that is controls code ideas situations files articles ways more knowledge knowledge points articles follow questions practices loops Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi macOS MariaDB Docker NVidia