AlibabaCloud 核⼼元件鏈路追蹤 Sleuth 和 zipking 實戰
阿新 • • 發佈:2020-11-13
1 Java程式碼
package com.example.myapplication; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.Toast; public class RadioActivity extends AppCompatActivity { private RadioGroup mRg1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.zhuce); mRg1 = findViewById(R.id.Rad1); mRg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int i) { RadioButton radioButton= radioGroup.findViewById(i); Toast.makeText(RadioActivity.this,radioButton.getText(),Toast.LENGTH_SHORT).show(); } }); } }
2 XML檔案
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<TextView
android:id="@+id/text1"
android:layout_width="600dp"
android:layout_height="38dp"
android:text="請選擇你的性別為:"
android:textSize="32dp"
android:textColor="#000000"/>
<RadioGroup
android:id="@+id/Rad1"
android:orientation="horizontal"
android:layout_below="@id/text1"
android:layout_width="wrap_content"
android:layout_height="32dp">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:textSize="20dp"
android:text="男"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:textSize="20dp"
android:text="女"/>
</RadioGroup>
<EditText
android:layout_marginTop="40dp"
android:id="@+id/Edi1"
android:layout_below="@id/Rad1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/bianjiziliao"
android:hint="請輸入使用者名稱:"
android:background="@drawable/button_zhuce"
android:maxLines="1" />
<EditText
android:id="@+id/Edi2"
android:layout_below="@id/Edi1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="請輸入手機號:"
android:drawableLeft="@drawable/shouji"
android:background="@drawable/button_zhuce"
android:maxLines="1" />
<EditText
android:id="@+id/Edi3"
android:layout_below="@id/Edi2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="請輸入郵箱:"
android:drawableLeft="@drawable/youxiang"
android:background="@drawable/button_zhuce"
android:maxLines="1" />
<EditText
android:id="@+id/Edi4"
android:layout_below="@id/Edi3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_zhuce"
android:hint="請輸入密碼:"
android:drawableLeft="@drawable/mima"
android:maxLines="1" />
<EditText
android:id="@+id/Edi5"
android:layout_below="@id/Edi4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_zhuce"
android:hint="再次驗證密碼:"
android:drawableLeft="@drawable/mima"
android:maxLines="1" />
<TextView
android:layout_marginTop="30dp"
android:layout_below="@id/Edi5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="點選[註冊]按鈕即代表同意《老吳克註冊協議》"
android:gravity="center"
android:textColor="#ff9900"/>
<Button
android:layout_marginTop="60dp"
android:layout_below="@id/Edi5"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textColor="#ffffff"
android:background="@drawable/bg_btn4"
android:text="註冊"
android:textSize="20dp"/>
</RelativeLay