title: How to inflate an Intent in a fragment using achartengine
body: <p>The code below works, but the whole main view is replaced for the chart when I invoke itself.</p>
  
  <p>I guess that the problem is located in how I start the chart Activity in startActivity(chart); in my framgment. If remove it, the fragment works well without replacement.</p>
  
  <p>How could I send it to the main view???</p>
  
  <pre><code>public class Graph extends Fragment {
  
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
  
  
      // LineGraph - class which draws the graph using achartengine
      final LineGraph lineGraph = new LineGraph();
      final Intent chart = lineGraph.getIntent(inflater.getContext());
  
      startActivity(chart);
  
      return inflater.inflate(R.layout.graph1, container, false);  
  
  }
  
  }
  </code></pre>
  
  <p>Here the Activity:</p>
  
  <pre><code>    public class MainCharts extends Activity {
      Button btn1;
  
      @TargetApi(11)
      protected void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.dash_app);
  
          btn1=(Button)findViewById(R.id.button1);
  
          FragmentManager fm = getFragmentManager();
          FragmentTransaction ft = fm.beginTransaction();
  
          StartFragment myFragment = new StartFragment();
          ft.add(R.id.myFragment, myFragment);
          ft.commit();
  
          btn1.setOnClickListener(btnOnClickListener);
  
      }
  
      Button.OnClickListener btnOnClickListener = new Button.OnClickListener(){
  
          @SuppressLint("NewApi")
          @Override
          public void onClick(View v){
  
              Fragment newFragment;
  
              newFragment = new Graph();
  
              FragmentTransaction transaction = getFragmentManager().beginTransaction();
              transaction.replace(R.id.myFragment, newFragment);
              transaction.addToBackStack(null);
              transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
              transaction.commit();
          }
      };
  }
  </code></pre>