我有一个基于布尔选项创建的视图,该视图的标题为 socialoptions,它在单独的 xml 文件中定义。每当我尝试通过诸如socialoptions.setClickable(true);
.
Java 代码:
if (isUserProfile) {
Log.d("user","user");
middlelayout = (LinearLayout) findViewById (R.layout.usermiddlelayout);
} else {
Log.d("item","item");
middlelayout = (LinearLayout) findViewById (R.layout.itemmiddlelayout);
socialoptions = (TextView) findViewById (R.id.socialoptions);
map = (TextView) findViewById (R.id.map);
}
XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/itemmiddlelayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="25"
android:background="@android:color/transparent"
android:clickable="false"
android:orientation="horizontal" >
<RelativeLayout
android:id="@+id/sociallayout"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@android:color/transparent"
android:paddingBottom="0dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView
android:id="@+id/socialoptions"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:clickable="false" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/maplayout"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:paddingBottom="10dp"
android:paddingTop="0dp" >
<TextView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:clickable="false" />
</RelativeLayout>
</LinearLayout>