资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Android中如何实现一个简易时间轴

这篇文章主要讲解了“Android中如何实现一个简易时间轴”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Android中如何实现一个简易时间轴”吧!

成都创新互联拥有一支富有激情的企业网站制作团队,在互联网网站建设行业深耕十多年,专业且经验丰富。十多年网站优化营销经验,我们已为上1000+中小企业提供了成都网站建设、成都做网站解决方案,按需网站制作,设计满意,售后服务无忧。所有客户皆提供一年免费网站维护!

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文件:


    



  

  

  

  

  


  
  

  

    

    
  




  

    

  

  

    

      

      

      

    

    

      

      

    
    

      
        
        

        
        
      


      


    
    

      
        
        

        
        
      


      


    

    

      

      
    


  
 

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中如何实现一个简易时间轴这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!


文章名称:Android中如何实现一个简易时间轴
链接分享:http://cdkjz.cn/article/gjopod.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220