Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.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
Android 文本查看网格项目单击更改颜色_Android_Gridview - Fatal编程技术网

Android 文本查看网格项目单击更改颜色

Android 文本查看网格项目单击更改颜色,android,gridview,Android,Gridview,我想在GridView显示的相对布局示例中更改textview的颜色,我想在网格项上的RelayvelLayout中更改textview的颜色单击其位置 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rel_bg" android:layout_width="60dp" android:layout_height="30dp" android:backg

我想在GridView显示的相对布局示例中更改textview的颜色,我想在网格项上的RelayvelLayout中更改textview的颜色单击其位置

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rel_bg"
android:layout_width="60dp"
android:layout_height="30dp"
android:background="@drawable/grid_item_bg"
android:orientation="vertical">

<TextView
    android:textColor="@drawable/state_rel"
    android:id="@+id/bTxt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="ABC"
    android:textSize="18sp" />


正如我对relativeLayout on grid Item clicked change background所做的那样,面临textview中的问题如何为textview编码无法理解这一点,请帮助:)谢谢.java文件中的,非常像AcitCity\u main:

首先,您必须通过以下语句初始化TextView:
TextView myTextView=(TextView)findViewById(R.id.myid)

您可以简单地说:
myTextView.setBackGroundColor(Color.argb(x1,x2,x3,x4);

x1-x4可以得到0到250之间的值。0非常亮,250非常暗

x1=不透明度

x2=红色

x3=绿色

x4=蓝色

例如:
myTextView.setBackgroundColor(Color.argb(250250,0,0);

将设置一个非常红色的背景。

请在我的grid ItemOnCLickListener方法视图中共享更改RelativeLayout背景的代码。setSelected(true);以及使用RelativeLayout的背景色您可以通过编程方式为任何视图设置背景色:
myView.setBackground(color.red)
好的,我知道,但是你能帮我改变文本视图的颜色吗?不:/不想设置背景,想设置文本颜色…你不明白…这个布局设计是在gridview中使用适配器的…如果我像你说的那样做,它会改变所有的