我正在使用以下代碼。在相對佈局上更改touchevent的背景顏色
<RelativeLayout
android:layout_width="310dp"
android:layout_height="70dp"
android:layout_below="@+id/UIReportView"
android:layout_marginLeft="4dp"
android:layout_marginTop="2dp"
android:background="@drawable/small_corners" >
small_corners
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/UINoCorners"
android:shape="rectangle">
<corners android:radius="10dp"/>
<padding android:left="10dp"
android:right="10dp"
android:top="5dp"
android:bottom="5dp"/>
<solid android:color="#FFFFFF"/>
</shape>
現在,它顯示了一個白條。我想,只要我點擊這個相對佈局,它的顏色應該改變,由我設置。
report = (RelativeLayout) findViewById(R.id.UIMainReportViewTimely);
report .setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
// My Code
}
});
我應該在這裏做什麼? report.onTouchEvent?
而我該如何改變背景的顏色。
問候
試過,我用不同的顏色,但它只是使它走到黑,不是我的願望 – 2012-03-28 10:05:42