码迷,mamicode.com
首页 > 移动开发 > 详细

android 时间轴

时间:2014-11-24 13:36:37      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:时间轴

效果图:

bubuko.com,布布扣bubuko.com,布布扣


scrollview+listView 叠加嵌套实现

禁止滑动ListView :

         

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;

public class MyListView extends ListView{  
	  
    public MyListView(Context context, AttributeSet attrs) {  
            super(context, attrs);  
    }  
      
    /** 
     * 设置不滚动 
     */  
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)  
    {  
            int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,  
                            MeasureSpec.AT_MOST);  
            super.onMeasure(widthMeasureSpec, expandSpec);  

    }  

}  
MainActivity:

     

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends Activity {

	private LinearLayout layout_parent1;
	private LinearLayout layout_parent2;
	private TextView year;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		layout_parent1=(LinearLayout)findViewById(R.id.layout_parent1);
		initView();
	}

	private void initView() {
		// TODO Auto-generated method stub
		ArrayList<AdapterBean> list=AdapterBean.getAdapterBeanCollection();
		for (int i = 0; i < list.size(); i++) {
			View view=getLayoutInflater().inflate(R.layout.item_scroll, null);
			layout_parent2=(LinearLayout)view.findViewById(R.id.layout_parent2);
			year=(TextView)view.findViewById(R.id.textView_year);
			year.setText(list.get(i).getYear());
			layout_parent2.addView(ChildView.getInstance(getLayoutInflater()).getView());
			layout_parent1.addView(view);
		}
	}


}

ChildView:

     

import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Toast;

public class ChildView implements OnItemClickListener{
	public static ChildView child=null;
	private static LayoutInflater inflater;
	public static ChildView getInstance(LayoutInflater layoutInflater) {
		// TODO Auto-generated method stub
		inflater=layoutInflater;
		return new ChildView(layoutInflater);
	}
	private View view;
	private MyListView noScrolistview;
	private MyAdapter adapter;
	public ChildView(LayoutInflater layoutInflater){
		view=layoutInflater.inflate(R.layout.item_main, null);
		initialization();
	}
	private void initialization() {
		// TODO Auto-generated method stub
		noScrolistview=(MyListView)view.findViewById(R.id.NoScrollListview);
		adapter=new MyAdapter(inflater,TestBean.getTestBeanCollection());
		noScrolistview.setAdapter(adapter);
		noScrolistview.setOnItemClickListener(this);	
	}
	public View getView() {
		// TODO Auto-generated method stub
		return view;
	}
	@Override
	public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {
		// TODO Auto-generated method stub
		Toast.makeText(inflater.getContext(), "Position:  "+position, Toast.LENGTH_SHORT).show();
	}

}
如果需要具体到号数分类,同理


android 时间轴

标签:时间轴

原文地址:http://blog.csdn.net/anddroid_lanyan/article/details/41442889

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!