-
Notifications
You must be signed in to change notification settings - Fork 327
Expand file tree
/
Copy pathBarFragment.java
More file actions
54 lines (48 loc) · 1.8 KB
/
BarFragment.java
File metadata and controls
54 lines (48 loc) · 1.8 KB
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
package com.dacer.androidchartsexample;
import android.app.Fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import java.util.ArrayList;
import im.dacer.androidcharts.BarView;
/**
* Created by Dacer on 11/15/13.
*/
public class BarFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_bar, container, false);
final BarView barView = (BarView) rootView.findViewById(R.id.bar_view);
// barView.setBarColorEmptyPart(Color.parseColor("#4CAF50"));
barView.setBarColorValuePart(Color.parseColor("#4CAF50"));
barView.setTextColor(Color.parseColor("#009688"));
Button button = (Button) rootView.findViewById(R.id.bar_button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
randomSet(barView);
}
});
randomSet(barView);
return rootView;
}
private void randomSet(BarView barView) {
int random = (int) (Math.random() * 20) + 6;
ArrayList<String> test = new ArrayList<String>();
for (int i = 0; i < random; i++) {
test.add("test");
test.add("pqg");
// test.add(String.valueOf(i+1));
}
barView.setBottomTextList(test);
ArrayList<Integer> barDataList = new ArrayList<Integer>();
for (int i = 0; i < random * 2; i++) {
barDataList.add((int) (Math.random() * 100));
}
barView.setDataList(barDataList, 100);
}
}