RadioButton 、RadioGroup
RadioButton :單選按鈕。
RadioGroup:一組RadioButton只能選一個,一定要放在同一 個RadioGroup裡面。
RadioButton 的屬性:
checked:true表示有勾取,false表示為勾取。
textColor:有三種方法
第一種:直接插入android:textColor = "@android:color/white";
第二種:
1. color.xml 增加
<color name="colorR"(可以自己取)>#FF0000</color>
或是在 drawable.xml增加
<drawable name="colorR">#FF0000</drawable>
2. activity_main 增加
顏色設在 color.xml
android:textColor = "@color/colorR";或是顏色設在 drawable.xmlandroid:textColor = "@drawable/colorR";第三種:1.修改主程式.java,放在onCreate,名稱為tv1tv1 = (TextView)this.findViewById(R.id.tv01);2. TextView的setTextColor設定文字顏色tv1.setTextColor(android.graphics.Color.Yellow)android.graphics.Color.Yellow-->系統顏色RadioGroup 的屬性:
checkedButton:RadioButton的預設選項。
例如:android:checkedButton="@+id/radioButton"---->
複製你要預選RadioButton的id 等於號後面
"@+id/radioButton"繼承 android.view.View的類別:background:RadioGroup 的背景。contentDescription:通常用在image view, 用來描述這張image,主要是用在給盲人使用, Android 有一個talk back 功能,如果開啟talk back功能,當有人按到image view,Android就會自動唸出 content description的內容。id:每一個項目都有一個獨一無二的號碼。onClick:在視圖被點擊時調用的方法的名稱。XML需要增加--->android:onClick="onClick".java需增加setOnClickListene
visibility:圖片是否看見。
visible:看得到。
invisible:看不見。
gone:隱藏。
按鈕的事件:setonclicklistener:按下按鈕的事件。setonLongclicklistener:按下長按按鈕的事件。setonFocuschangeclicklistener:按下按鈕焦點改變的事件。setonTouchclicklistener:按下按鈕處碰監聽的事件。參考文獻:Android - RadioButton Control https://www.tutorialspoint.com/android/android_radiobutton_control.htm Android RadioButton http://tw.gitbook.net/android/android_radiobutton_control.html [Android] 單選按鈕(RadioButton)之介紹 http://peimei0808.pixnet.net/blog/post/288375553-%5Bandroid%5D-%E5%96%AE%E9%81%B8%E6%8C%89%E9%88%95(radiobutton)%E4%B9%8B%E4%BB%8B%E7%B4%B9 [Android]多選一的單選鈕 (RadioButton) http://mangolai.blogspot.tw/2014/07/android-radiobutton.html 設定textview的顏色 http://fecbob.pixnet.net/blog/post/34682451-%E8%A8%AD%E5%AE%9Atextview%E7%9A%84%E9%A1%8F%E8%89%B2-setTextColor()的參數設置方式http://www.itread01.com/articles/1475955663.htmlTru Xi的相關與近況相關紀錄與Android App(checkedButton)http://androidxi.blogspot.tw/2014/11/blog-post_25.htmlRadioGroup checkedButton property http://stackoverflow.com/questions/11029635/radiogroup-checkedbutton-property RadioGroup checkedButton 不能用@id? http://www.eoeandroid.com/thread-1897-1-1.html [Android]基本的 Widget 元件介紹 (二) http://abgne.tw/android/android-code-snippets/basic-widgets-intro-2.html Radio group onclick event not firing, how do I tell which is selected? http://stackoverflow.com/questions/9748070/radio-group-onclick-event-not-firing-how-do-i-tell-which-is-selected 【转载】View的setOnClickListener的添加方法 http://king39461.pixnet.net/blog/post/357950016-%E3%80%90%E8%BD%AC%E8%BD%BD%E3%80%91view%E7%9A%84setonclicklistener%E7%9A%84%E6%B7%BB%E5%8A%A0%E6%96%B9%E6%B3%95 《Android》『Button』- Button 的基本用法 http://xnfood.com.tw/android-button/ Android - 基礎元件:各種 Button 比較 https://www.blogger.com/blogger.g?blogID=5349486813674913166#editor/target=post;postID=7717794580411238493;onPublishedMenu=allposts;onClosedMenu=allposts;postNum=0;src=link
沒有留言:
張貼留言