我有一個遊戲,我最近添加了一個全球高分功能,讓很多人不高興,所以我想添加禁用它的選項。 我所做的是這樣的:在我的設置活動的看法,我增加了以下內容:當用戶取消選中啓用高分有沒有辦法以編程方式禁用特定佈局中的所有項目?
<!-- High Score Tracking -->
<LinearLayout android:layout_weight="40"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:padding="5dip">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:text="@string/EnableHighscoreCBText"
android:id="@+id/EnableHighscoreCB" android:layout_width="fill_parent"
android:layout_height="wrap_content">
</CheckBox>
</LinearLayout>
<!-- High score specific settings -->
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:weightSum="100" android:padding="5dip">
<CheckBox android:text="@string/EnableShareScoresCBText"
android:id="@+id/EnableShareScoresCB" android:layout_width="fill_parent"
android:layout_height="wrap_content">
</CheckBox>
<TextView android:id="@+id/DefaultPlayerNameTv"
android:layout_width="wrap_content" android:layout_weight="30"
android:layout_height="wrap_content" android:text="@string/pDefName"
android:textSize="18sp">
</TextView>
<EditText android:id="@+id/PlayerNameEt"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/pNameDefVal" android:layout_weight="70"
android:textSize="18sp" android:maxLength="20">
</EditText>
</LinearLayout>
</LinearLayout>
我想要做的是禁用整個「高分特定設置」佈局跟蹤複選框。 我試圖通過將setEnabled
設置爲false來禁用它,但那根本不起作用。 我應該使用視圖組還是其他? 我應該運行刷新方法來應用更改嗎?
您設置setEnabled哪個視圖?你在尋找什麼樣的效果?如果你只是想隱藏整個部分,你可以在linearLayout上設置visibility = GONE。 – 2010-09-29 00:45:14
我不是想要隱藏它,我希望它顯示,但作爲殘疾人(讓人們知道它在那裏,但會看到他們不能改變它) – ekatz 2010-09-29 05:45:26