je suis un développeur Android débutant et je en train de développer une application pour faire un Chronogramme, j'ai comme entré une liste d'objet contenant le début et la fin de chaque période mais j'ai pas réussi pour dessiner ce chronogramme w j'ai besoin de votre aide svp.

c'est le code que j'ai essayé:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
public class TourTimingAdapter extends ArrayAdapter<TourExt> {
 
	private Context context;
	private int layoutResourceId;
	private List<TourExt> data = null;
	private LayoutInflater mInflater;
	private long idOfGuard;
 
	private static final String dateTemplate = "HH:mm";
	public static int i = 1;
	private int textWidth;
	@SuppressLint("SimpleDateFormat")
	private final SimpleDateFormat df = new SimpleDateFormat(dateTemplate);
 
	public TourTimingAdapter(Context context, int layoutResourceId, List<TourExt> data) {
		super(context, layoutResourceId, data);
 
		this.context 			= context;
		this.layoutResourceId 	= layoutResourceId;
		this.data 				= data;
		mInflater 				= (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
 
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
 
		View row = convertView;
		RouteHolder holder = null;
 
		if (row == null) {
			row = mInflater.inflate(layoutResourceId, parent, false);
 
			holder 				= new RouteHolder();
			holder.number = (TextView) row.findViewById(R.id.numberDate);
			holder.lay 			= (LinearLayout) row.findViewById(R.id.layPlage);
 
			row.setTag(holder);
		} else {
			holder = (RouteHolder) row.getTag();
		}
 
		//initialize layout
		holder.lay.removeAllViews();
		TourExt tourExt = data.get(position);
 
		Date beginPlage = tourExt.getBegin();
		Date endPlage = tourExt.getEnd();
 
		Calendar cal = Calendar.getInstance();
		cal.setTime(beginPlage);
 
		float from = 0;
		if(cal.get(Calendar.HOUR_OF_DAY) != 0)
			from = (float) cal.get(Calendar.HOUR_OF_DAY)/(float)24;
		else 
			from = (float) (cal.get(Calendar.HOUR_OF_DAY) + 1)/(float)24;
		cal.setTime(endPlage);
		float to = 0;
		if(cal.get(Calendar.HOUR_OF_DAY) != 0)
			to = (float) cal.get(Calendar.HOUR_OF_DAY)/(float)24;
		else 
			from = (float) (cal.get(Calendar.HOUR_OF_DAY) + 1)/(float)24;
 
		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		Display display = wm.getDefaultDisplay();
 
//					Point size = new Point();
//					display.getSize(size);
//					LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
//				    llp.setMargins(5, 5, 5, 5); // llp.setMargins(left, top, right, bottom);
//				    
//					holder.plage.setLayoutParams(llp);
		float width;
		if (Integer.valueOf(android.os.Build.VERSION.SDK_INT) < 13 ) {
			width = display.getWidth();
	        //height = display.getHeight();
	       } else {
	    	   Point size = new Point();
	           display.getSize(size);
	           width = size.x;
	           //height = size.y;
	       }
 
		/*final TextView upV = (TextView)row.findViewById(R.id.numberDate);
		   ViewTreeObserver vto = upV.getViewTreeObserver();
		    vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
		        @Override
		        public void onGlobalLayout() {
 
		            Log.d("W ", ""+upV.getWidth());
		            Log.d("H ", ""+upV.getHeight());
		        }
		    });*/
 
		int marginleft = (int)(from * (float)(width - /*textWidth*/ 45));
		int marginright = (int)(to * (float)(width  - /*textWidth*/ 45));
 
		Log.d("TourTimingAdapter",  "width =   " + width + "from =   " + from + "  " + marginleft + "  " + to + " " + ((int)width - marginright) + "  " + width);
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
 
		//params.setMargins(marginleft, 5, (int)width - marginright, 5);
		params.setMargins(marginleft, 5, (int)width - marginright - 45, 5);
		//MarginLayoutParams marginLayoutParams = (MarginLayoutParams) params.getLayoutParams();
 
		//marginLayoutParams.setMargins(marginleft, 5, display.getWidth() - marginright, 5);
		TextView newplage = new TextView(context);
		newplage.setLayoutParams(params);
		newplage.setBackgroundColor(context.getResources().getColor(R.color.darkorrange));
 
		//newplage.setLayoutParams(marginLayoutParams);
 
		ActionItem fromItem = new ActionItem(ActionParameter3D.ID_DOWN, "From :" + df.format(beginPlage), context.getResources().getDrawable(R.drawable.planning_icon));
		ActionItem toItem = new ActionItem(ActionParameter3D.ID_DOWN, "		 To :" + df.format(endPlage), null);
		//ActionItem everyItem = new ActionItem(ActionParameter3D.ID_DOWN, "		 Every :" + myPlannig.getEvery() + " minutes", null);
		fromItem.setSticky(true);
		toItem.setSticky(true);
		//everyItem.setSticky(true);
 
		final QuickActionMap quickAction = new QuickActionMap(context, QuickActionMap.VERTICAL);
 
		//add action items into QuickAction 
        quickAction.addActionItem(fromItem);
        quickAction.addActionItem(toItem);
        //quickAction.addActionItem(everyItem);
 
		newplage.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				quickAction.setAnimStyle(QuickActionMap.ANIM_REFLECT);
				quickAction.show(v);
			}
		});
		//holder.lay.setBackground(context.getResources().getDrawable(R.drawable.planning_back));
		holder.lay.addView(newplage);
 
//	else{
//		//row.set
//		return null;
//	}
		holder.number.setText(" " + i + " ");
		return row;
	}
 
	class RouteHolder {
		TextView number;
		LinearLayout lay;
	}
}