android - Color of title bar -
how change color of title bar clicking button. have group of buttons represent different colors once 1 of button clicked should change color of title bar activities in application.
<?xml version="1.0" encoding="utf-8"?> <radiogroup xmlns:android="schemas.android.com/apk/res/android"; android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <radiobutton android:id="@+id/radio_blue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pirates" android:onclick="onradiobuttonclicked"/> <radiobutton android:id="@+id/radio_red" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/ninjas" android:onclick="onradiobuttonclicked"/> </radiogroup>
the code provided in comment:
<radiogroup xmlns:android="schemas.android.com/apk/res/android"; android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <radiobutton android:id="@+id/radio_blue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pirates" android:onclick="onradiobuttonclicked"/> <radiobutton android:id="@+id/radio_red" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/ninjas" android:onclick="onradiobuttonclicked"/> </radiogroup>
in order handle onclick events, have use activity class handle action.
you can start:
public class mainactivity extends activity { textview title; radiobutton red_button, blue_button, ...; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.[your xml name]); //getting widget references title = (textview) findviewbyid(r.id.title); red_button = (radiobutton) findviewbyid(r.id.radio_red); //handle onclick events red_button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { title.settextcolor(color.parsecolor("#ff0000")); } }); } }
Comments
Post a Comment