Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Android.Widget.TextView_C#_Android_Widget_Textview_Monodevelop - Fatal编程技术网

C# Android.Widget.TextView

C# Android.Widget.TextView,c#,android,widget,textview,monodevelop,C#,Android,Widget,Textview,Monodevelop,我正在尝试在Android MonoDevelop中更改textview的颜色 我试过这个: TextView mapTextView = new TextView(contextOverlay); mapTextView.Text = overlayDetailsForThisOverlay.stringName; mapTextView.setTextColor(Color.RED); 我得到以下错误: Android.Widget.TextView不包含setTextColor的定

我正在尝试在Android MonoDevelop中更改
textview
的颜色

我试过这个:

TextView mapTextView = new TextView(contextOverlay); 
mapTextView.Text = overlayDetailsForThisOverlay.stringName; 
mapTextView.setTextColor(Color.RED); 
我得到以下错误:

Android.Widget.TextView
不包含
setTextColor
的定义

我已尝试添加以下内容作为using语句:

using `Android.Graphics`; 
没有运气


我能帮点忙吗?

我不明白您是要更改背景颜色还是文本颜色。无论如何,要更改文本颜色,应使用以下命令:

TextView tv=new TextView(this);
tv.setTextColor(Color.argb(255, 255, 0, 0));//ARGB 255 255 0 0 is red
tv.SetTextColor(Resources.GetColorStateList(Resource.Color.textcolor));
要更改背景色,请执行以下操作:

TextView tv=new TextView(this);
tv.setBackgroundColor(Color.argb(255, 0, 255, 0));//ARGB 255 0 255 0 is green
别忘了将其放入您的导入中:

import android.graphics.Color;

要更改文本视图的颜色,应使用以下命令:

TextView tv=new TextView(this);
tv.setTextColor(Color.argb(255, 255, 0, 0));//ARGB 255 255 0 0 is red
tv.SetTextColor(Resources.GetColorStateList(Resource.Color.textcolor));
但首先必须在Values文件夹中创建一个xml文件(Color.xml),其中包含以下代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="textcolor">#ffcc33</color>
</resources>

#ffcc33