codingdir logo sitemap sitemap |
Home
PHP
C#
C++
ANDROID
JAVA
JAVASCRIPT
PYTHON

Android: achartEngine with fragments


By : , Category : android

Put this code in onActivityCreated

 initChart();
 addSampleData();
 mChart = ChartFactory.getCubeLineChartView(getActivity(), mDataset, mRenderer, 0.3f);
 layout.addView(mChart);`
ReLated :

Use this in place of ur replaceFragment()

 public void replaceFragment(int position) {
     FragmentTransaction fragTransaction = mFragmentManager
             .beginTransaction();
     fragTransaction.replace(R.id.frame, fragments.get(position));
     fragTransaction.addToBackStack(null).commit();
 }

and onresume()

public void onResume()
    {
        super.onResume();
        System.out.println("onResume called");
        View view = this.getView();
        if(mChartView == null)
        {
            LinearLayout layout = (LinearLayout) view.findViewById(R.id.chart);
            mChartView = ChartFactory.getLineChartView(getActivity(), mDataset, mRenderer);
            layout.addView(mChartView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        }
        else
        {
            mChartView.repaint();
        }
    }

Try to use this method and see if it improves things:

renderer.setXRoundedLabels(false);

You're attaching each of those views to the container

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView;
    switch(getArguments().getInt(ARG_SECTION_NUMBER)){ 

        case 1: 
            rootView = inflater.inflate(R.layout.fragment_introduction, container, false);
            break; 

        case 2: 
            rootView = inflater.inflate(R.layout.fragment_blank, container, false);
            break; 

    }
    return rootView;
}

I would highly recommend finding a different solution to this. Perhaps just create another fragment with the second view. Maintaining this looks like it would be a disaster.

Why do you inflate your view in the DetailsFragment if you return the view of superclass? This does not make any sense. You shoud do following

public class DetailsFragment extends Fragment
{
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
    final View view = inflater.inflate(R.layout.fragment_details, container, false);

    return view;
    }
}
Comments


Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © codingdir.com All Rights Reserved .