这期内容当中小编将会给大家带来有关Android中怎么实现一个简易时间轴,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
创新互联专注为客户提供全方位的互联网综合服务,包含不限于成都做网站、成都网站制作、成都外贸网站建设、滨江网络推广、微信小程序开发、滨江网络营销、滨江企业策划、滨江品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们大的嘉奖;创新互联为所有大学生创业者提供滨江建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com1.新建一个自定义控件:
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文件:
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中怎么实现一个简易时间轴了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。