0

I've used the this reference to display the line graph By above code, graph gets displayed on separate view. I want to display it in particular area of view and not as new view. So, I used this snippet

 layout.addView(graphView, 200, 250);

This works fine but the issue is how do I specify the starting co-ordinates for this view. It's getting placed at left top. I want it at some particular position.

THANKS IN ADVANCE !!

GAMA
  • 5,958
  • 14
  • 79
  • 126

1 Answers1

1

After adding view in layout, try using LayoutParams to set attributes of it. I think that way you can set X and Y co-ordinate of view.

Veljko
  • 1,893
  • 6
  • 28
  • 58
  • Yeah, thnx. It's working but I'm having prob with `onConfigurationChanged()`. It all works in fine in portrait mode, but when switched to landscape mode, it gives `nullPointerException` as I'm referring to layout of `main.xml` within `layout` folder and not `main.xml` from `laypot-land` folder. – GAMA Dec 16 '11 at 09:16
  • im not quite sure that i understand your problem... When i need to save state of app when mode is changing...i use onInstanceSave and onInstaceRestore methods. http://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state Take look at this, maybe you'll solve your problem. – Veljko Dec 16 '11 at 14:18
  • This ex. is only saving some variables like String,int,etc. I want to prevent activity from re-starting? – GAMA Dec 17 '11 at 04:23
  • im quite sure that u can prevent that. Read about life cycle of activity. On orientation change activity goes in onCreate method and so on. U need to save all of your important data, and re-use it again. – Veljko Dec 17 '11 at 11:49