标签:
1.效果图 2.源代码 MainActivity.java public class MainActivity extends AppCompatActivity { public enum ChartType { LINE_CHART, COLUMN_CHART, PIE_CHART, BUBBLE_CHART, PREVIEW_LINE_CHART, PREVIEW_COLUMN_CHART, OTHER } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit(); } } public static class PlaceholderFragment extends Fragment implements AdapterView.OnItemClickListener { private ListView listView; private ChartSamplesAdapter adapter; public PlaceholderFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); listView = (ListView) rootView.findViewById(android.R.id.list); adapter = new ChartSamplesAdapter(getActivity(), 0, generateSamplesDescriptions()); listView.setAdapter(adapter); listView.setOnItemClickListener(this); return rootView; } @Override public void onItemClick(AdapterView> adapter, View view, int position, long id) { Intent intent; switch (position) { case 0: // Line Chart; intent = new Intent(getActivity(), LineChartActivity.class); startActivity(intent); break; case 1: // Column Chart; intent = new Intent(getActivity(), ColumnChartActivity.class); startActivity(intent); break; case 2: // Pie Chart; intent = new Intent(getActivity(), PieChartActivity.class); startActivity(intent); break; default: break; } } private Listhellocharts-android开源图表库(一)线状图
标签:
原文地址:http://www.cnblogs.com/520-1314/p/5532154.html