1

How to add a chart (from teechart library) to a layout that i created in xamarin android application?

Examples/tutorials that i found are changing all content view by using setcontentview method as follows.

However, I would like to add this as part of a layout.

Avi
  • 21,182
  • 26
  • 82
  • 121
alper
  • 11
  • 2

2 Answers2

2

Yes, this is possible as adding any other object to a layout, just use the AddView method with desired LayoutParams, for example:

Steema.TeeChart.TChart tChart1 = new Steema.TeeChart.TChart(this); 
RelativeLayout rLayout = new RelativeLayout(this);

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(400, 400);
lp.LeftMargin = 0;
lp.TopMargin = 0;

rLayout.AddView(tChart1, lp);
Narcís Calvet
  • 7,304
  • 5
  • 27
  • 47
  • it doesn't work. i think, its searching tags in axml file, we didn't add something there – alper Apr 08 '14 at 18:38
  • @alper this code doesn't need axml code. If you send us a simple example project we can run "as-is" to reproduce the problem here, I'll try to help you solve the problem. However, the basic idea is using AddView method with desired LayoutParams. You can send your files at http://www.steema.net/upload – Narcís Calvet Apr 10 '14 at 07:11
0

Ok man take a look at this line:

  Steema.TeeChart.TChart tChart1 = new Steema.TeeChart.TChart(this); 

It seems a view declaration, have you tried to add it on your xml file and then casting it using findViewById? This way you could add it as another view on your layout.

JasJar
  • 336
  • 3
  • 14
  • i can't add to my xml file, because it is not a default android tool so has not a xml tag (like textbox, label etc.) – alper Apr 07 '14 at 19:20