TextView Color for Android
Possible Duplicate:
How to set text color of TextView by coding?
Here is my code:
TextView mapTextView = new TextView(contextOverlay);
mapTextView.Text = overlayDetailsForThisOverlay.stringName;
May I please have some help to change the text color for this text.
The documentation appears to show that there is a 'setTextColor' method.
I am new to Android programming. Do I need to set up an XML file (I am not sure of how/why to do this).
Thanks
Yes, you should set up an XML file for all of your activities. You can change things programatically when needed but it is usually easier to set these up initially in an XML then use setContentView(R.layout.yourxmlfile) to set your initial UI. See here for more details on layout files. In the XML, you can set your text color and many other attributes and change them in your Java code if needed. I don't know what your contextOverlay is but you would want to declare your TextView with something like
TextView mapTextView = (TextView) findViewById(R.id.nameofid)
You should put all of your layouts for UI's in the layout folder and any hard-coded words should be in the res/values/strings folder and accessed there from your XML layouts. Go through the documentation and it will show you how to set all of that up
上一篇: 以编程方式减轻颜色