0
У меня есть API, и есть значение широковещательной передачи, и параметры являются общедоступными, частными, вошедшими в систему и незарегистрированными. Я хочу, чтобы радиообъект был выбран как публичный, если трансляция публична.Как выбрать RadioButton
Это мой XML-код:
<TextView
android:textColor="#060606"
android:layout_marginTop="10dp"
android:textSize="15sp"
android:text="Broadcast Options"
android:id="@+id/broadcast_head"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioGroup
android:orientation="vertical"
android:id="@+id/radio_group_broadcast"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:textSize="16sp"
android:text="Public"
android:id="@+id/radio_button_public"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:textSize="16sp"
android:text="Private"
android:id="@+id/radio_button_private"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:textSize="16sp"
android:text="Unlisted"
android:id="@+id/radio_button_unlisted"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:textSize="16sp"
android:text="Logged Only"
android:id="@+id/radio_button_logged_only"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RadioGroup>
</TextView>
и это мой Java-код; Я не знаю, правильный ли этот код или нет.
rbPub = (RadioButton)findViewById(R.id.radio_button_public);
rbPri = (RadioButton)findViewById(R.id.radio_button_private);
rbUnl = (RadioButton)findViewById(R.id.radio_button_unlisted);
rbOnl = (RadioButton)findViewById(R.id.radio_button_logged_only);
radioGroup1 = (RadioGroup) findViewById(R.id.radio_group_broadcast);
VideoDetail videoDetailBroadcast = null; //this is the problem, can't fix(null)
if (videoDetailBroadcast.isPublic()) {
rbPub.setChecked(true);
}
else if (videoDetailBroadcast.isPrivate()) {
rbPri.setChecked(true);
}
else if (videoDetailBroadcast.isUnlisted()) {
rbUnl.setChecked(true);
}
else if (videoDetailBroadcast.isLoggedOnly()) {
rbOnl.setChecked(true);
}
Есть 'BroadcastReceiver' установить где-нибудь? Что такое «VideoDetail» и как/где вы ожидаете изменения значения? – codeMagic