当我更改微分值时,即使TAB1处于活动状态并显示在屏幕上,图表也会在TAB2上更新,但不会在TAB1中更新。
这是我的代码......
onCreateView:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_charts_line, container, false);
layoutChart = (LinearLayout) rootView.findViewById(R.id.chart);
...all renderer settings...
return rootView;
onViewCreated:
public void onViewCreated(View view, Bundle savedInstanceState){
Toolbar mToolbar = (Toolbar) getActivity().findViewById(R.id.toolbar_actionbar);
final Spinner spinner_nav = (Spinner) mToolbar.findViewById(R.id.spinner_nav);
spinner_nav.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
cSpinner = spinner_nav.getSelectedItem().toString();
showChart(cSpinner);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
cSpinner= spinner_nav.getSelectedItem().toString();
showChart(cSpinner);
}
showChart:
public void showChart(String account){
if (mChartView == null) {
LinearLayout layout = (LinearLayout) layoutChart.findViewById(R.id.chart);
mChartView = ChartFactory.getTimeChartView(layoutChart.getContext().getApplicationContext(), mDataset, mRenderer, "MMM yyyy");
layout.addView(mChartView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
} else {
mChartView.repaint();
}
}
我想要的是更新每个标签中的所有图表,或者至少更新当前标签中的图表。每个选项卡片段中的每个变量名称都不同。