最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android RadioGroup的使用方法

 更新時(shí)間:2012年11月09日 09:51:31   作者:  
android RadioGroup的使用方法,需要的朋友可以參考下
創(chuàng)建一個(gè)MainActivity.java的主類(lèi)
復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/radiobutton_textview"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:textSize="18dip"
android:textStyle="bold"
android:background="@android:drawable/title_bar"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
/>
<RadioGroup
android:id="@+id/group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:textSize="20dip"
android:paddingLeft="30dip"
android:text="Android新手"
android:button="@null"
android:drawableRight="@android:drawable/btn_radio"/>
<View
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="?android:attr/listDivider"
/>
<RadioButton
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:textSize="20dip"
android:paddingLeft="30dip"
android:text="Android高手"
android:button="@null"
android:drawableRight="@android:drawable/btn_radio"/>
</RadioGroup>
</LinearLayout>

Xml代碼
復(fù)制代碼 代碼如下:

package endual.radio;
import android.app.Activity;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
public class MainActivity extends Activity {
private TextView textView;
private RadioGroup group;
private RadioButton rb1 ;
private RadioButton rb2 ;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textView = (TextView) findViewById(R.id.radiobutton_textview);
group = (RadioGroup) findViewById(R.id.group);
this.rb1 = (RadioButton) this.findViewById(R.id.button1) ;
this.rb2 = (RadioButton) this.findViewById(R.id.button2) ;

// 單選按鈕組監(jiān)聽(tīng)事件
group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// 根據(jù)ID判斷選擇的按鈕
if (checkedId == R.id.button1) {

textView.setText("Android新手");
rb1.setText("我是1") ;
String msg = rb1.getText().toString() ; //獲取單獨(dú)的radioButton的按鈕
rb2.setText(msg) ;
//System.out.println();
} else {
textView.setText("Android高手");
rb2.setText("我是2") ;
}
}
});
}
}

RadioGroup注冊(cè)監(jiān)聽(tīng)事件OnCheckedChangeListener(),在onCheckedChanged實(shí)現(xiàn)業(yè)務(wù)邏輯。

相關(guān)文章

  • Flutter?SystemChrome控制應(yīng)用程序的系統(tǒng)級(jí)別行為

    Flutter?SystemChrome控制應(yīng)用程序的系統(tǒng)級(jí)別行為

    這篇文章主要為大家介紹了Flutter?SystemChrome用來(lái)控制應(yīng)用程序的系統(tǒng)級(jí)別行為步驟詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-05-05
  • 詳解四種主要的Android依賴(lài)管理方式

    詳解四種主要的Android依賴(lài)管理方式

    Android應(yīng)用開(kāi)發(fā)涉及大量的依賴(lài)庫(kù)和第三方組件,因此有效地管理這些依賴(lài)關(guān)系至關(guān)重要,本文將介紹四種主要的Android依賴(lài)管理方式,分析它們的優(yōu)點(diǎn)、缺點(diǎn)以及最佳實(shí)踐,需要的朋友可以參考下
    2023-09-09
  • Android編程實(shí)現(xiàn)Dialog窗體監(jiān)聽(tīng)的方法

    Android編程實(shí)現(xiàn)Dialog窗體監(jiān)聽(tīng)的方法

    這篇文章主要介紹了Android編程實(shí)現(xiàn)Dialog窗體監(jiān)聽(tīng)的方法,結(jié)合實(shí)例形式分析了Android針對(duì)Dialog對(duì)話框窗體事件監(jiān)聽(tīng)與響應(yīng)相關(guān)操作技巧,需要的朋友可以參考下
    2017-03-03
  • Android獲取手機(jī)型號(hào)/系統(tǒng)版本號(hào)/App版本號(hào)等信息實(shí)例講解

    Android獲取手機(jī)型號(hào)/系統(tǒng)版本號(hào)/App版本號(hào)等信息實(shí)例講解

    本示例獲得手機(jī)型號(hào),系統(tǒng)版本,App版本號(hào)等信息,具體實(shí)現(xiàn)如下,感興趣的朋友可以參考下哈
    2013-06-06
  • Android Studio中引入Lambda表達(dá)式的方法

    Android Studio中引入Lambda表達(dá)式的方法

    這篇文章主要給大家介紹了在Android Studio中引入Lambda表達(dá)式的方法,文中通過(guò)圖文介紹的非常詳細(xì),對(duì)大家具有一定的參考價(jià)值,需要的朋友們下面來(lái)一起看看吧。
    2017-03-03
  • Android通話默認(rèn)打開(kāi)揚(yáng)聲器的方法

    Android通話默認(rèn)打開(kāi)揚(yáng)聲器的方法

    這篇文章主要介紹了Android通話默認(rèn)打開(kāi)揚(yáng)聲器的方法.小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08
  • Android LinearLayout實(shí)現(xiàn)自動(dòng)換行

    Android LinearLayout實(shí)現(xiàn)自動(dòng)換行

    這篇文章主要為大家詳細(xì)介紹了Android LinearLayout實(shí)現(xiàn)自動(dòng)換行,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-08-08
  • Android Studio Gradle插件版本與Gradle版本之間的對(duì)應(yīng)關(guān)系

    Android Studio Gradle插件版本與Gradle版本之間的對(duì)應(yīng)關(guān)系

    今天小編就為大家分享一篇關(guān)于Android Studio Gradle插件版本與Gradle版本之間的對(duì)應(yīng)關(guān)系,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2018-12-12
  • android實(shí)現(xiàn)簡(jiǎn)單儀表盤(pán)效果

    android實(shí)現(xiàn)簡(jiǎn)單儀表盤(pán)效果

    這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)簡(jiǎn)單儀表盤(pán)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-05-05
  • Android Crash與ANR詳細(xì)介紹

    Android Crash與ANR詳細(xì)介紹

    對(duì)于Android開(kāi)發(fā)的人來(lái)說(shuō),想必對(duì)Crash和ANR這倆都不陌生,并且都對(duì)其恨之入骨,因?yàn)樗鼈z的產(chǎn)生會(huì)大大影響用戶(hù)體驗(yàn)。所以,在此,結(jié)合本人的開(kāi)發(fā)經(jīng)驗(yàn),對(duì)其做個(gè)總結(jié)
    2022-11-11

最新評(píng)論

阿鲁科尔沁旗| 银川市| 彰化市| 家居| 新竹市| 贵港市| 德昌县| 鲁山县| 石城县| 孙吴县| 封开县| 鲁甸县| 宕昌县| 江西省| 威海市| 阿尔山市| 曲阜市| 手游| 望江县| 谷城县| 万山特区| 临沧市| 天等县| 潮州市| 晋州市| 柳州市| 白玉县| 夏津县| 凉山| 黎川县| 临泉县| 金昌市| 江城| 太保市| 普兰县| 辉县市| 哈巴河县| 林周县| 科技| 南靖县| 左云县|