CheckBoxActivity.java
package archie.android.activity; import android.app.Activity; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.TextView; import android.widget.Toast; public class CheckBoxActivity extends Activity { private TextView textView; private CheckBox checkBox1; private CheckBox checkBox2; private CheckBox checkBox3; private CheckBox checkBox4; private Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textView=(TextView) findViewById(R.id.TextView01); checkBox1=(CheckBox) findViewById(R.id.CheckBox01); checkBox2=(CheckBox) findViewById(R.id.CheckBox02); checkBox3=(CheckBox) findViewById(R.id.CheckBox03); checkBox4=(CheckBox) findViewById(R.id.CheckBox04); button=(Button) findViewById(R.id.button1); checkBox1.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(checkBox1.isChecked()){ DisplayToast("你選擇了:"+checkBox1.getText()); } }}); checkBox2.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(checkBox2.isChecked()){ DisplayToast("你選擇了:"+checkBox2.getText()); } }}); checkBox3.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(checkBox3.isChecked()){ DisplayToast("你選擇了:"+checkBox3.getText()); } }}); checkBox4.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(checkBox4.isChecked()){ DisplayToast("你選擇了:"+checkBox4.getText()); } }}); button.setOnClickListener(new Button.OnClickListener(){ @Override public void onClick(View v) { int num=0; if(checkBox1.isChecked()){ num++; } if(checkBox2.isChecked()){ num++; } if(checkBox3.isChecked()){ num++; } if(checkBox4.isChecked()){ num++; } DisplayToast("你一共選擇了:"+num+"項"); }}); } public void DisplayToast(String str){ Toast toast=Toast.makeText(this, str, Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP, 0, 220); toast.show(); } }
main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/TextView01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/check" /> <CheckBox android:id="@+id/CheckBox01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/CheckBox01" /> <CheckBox android:id="@+id/CheckBox02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/CheckBox02"/> <CheckBox android:id="@+id/CheckBox03" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/CheckBox03"/> <CheckBox android:id="@+id/CheckBox04" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/CheckBox04"/> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button1"/> </LinearLayout>
String.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">CheckBox</string> <string name="check">調查:你喜歡Andorid的原因?</string> <string name="CheckBox01">無界限的應用程序</string> <string name="CheckBox02">應用程序在平等條件下創建</string> <string name="CheckBox03">應用程序可以輕鬆地進入網絡</string> <string name="CheckBox04">應用程序可以並行運行</string> <string name="button1">提交</string> </resources>
本文分享自華爲雲社區《10分鐘搞懂各種內存溢出案例!!(含完整源碼,建議收藏)》,作者:冰 河。 作爲程序員,多多少少都會遇到一些內存溢出的場景,如果你還沒遇到,說明你工作的年限可能比較短,或者你根本就是個假程序員!哈哈,開個玩笑。今天,我
文件位置:./gradle/init.gradle def repoConfig = { all { ArtifactRepository repo -> if (repo instanceof MavenArtif
方案概述 在汽車發展和用戶需求的推動下,汽車鑰匙開始從傳統的機械鑰匙向數字化、智能化方向發展。目前常見的數字鑰匙集成了藍牙、NFC、UWB等技術實現了移動設備與車端的通信,可以幫助用戶便捷的實現車輛功能控制。隨着數字鑰匙的廣泛
在Vue中,style scope是一個特性,它可以防止組件的樣式影響到其他組件,從而減少樣式衝突。這個特性通過在生成的CSS選擇器中自動添加一個屬性(通常是data-v-hash)來實現。 如果你遇到了style scope導致樣式無法被
DevExtreme擁有高性能的HTML5 / JavaScript小部件集合,使您可以利用現代Web開發堆棧(包括React,Angular,ASP.NET Core,jQuery,Knockout等)構建交互式的Web應用程序。從Ang
在windows環境,springboot 處理提交的json數據報錯“com.fasterxml.jackson.databind.JsonMappingException: Invalid UTF-8 start byte 0xb1”。
文|苟振東(花名:盛知) Koupleless 項目 committer 螞蟻集團技術專家 本文 5789 字 閱讀 12 分鐘 本篇文章屬於 Koupleless 進階系列文章第二篇,默認讀者對 Koupleless 的基礎概念、能力都
1. 引言 在現代軟件開發過程中,性能優化和故障排查是保證應用穩定運行的關鍵任務之一。Java作爲一種廣泛使用的編程語言,其生態中湧現出了許多優秀的監控和診斷工具,諸如:SkyWalking、Zipkin等,它們幫助開發者和運維人員
· 前言 · 在國內,公網服務器與本地服務器的通信一直是個難題,本地服務器因爲IP是動態變化的,公網服務器沒辦法將請求發送給本地服務器。爲了解決這個問題,所以採用WebSocket協議替換Http協議。爲了實現請求等待,使用Gu
在這裏分享一下通過拖取 DataCube 代碼審計後發現的一些漏洞,包括前臺的文件上傳,信息泄露出賬號密碼,後臺的文件上傳。當然還有部分 SQL 注入漏洞,因爲 DataCube 採用的是 SQLite 的數據庫,所以SQL 注入相對來說顯
轉載自劉茫茫看山 問題背景 某天我們的租戶反饋數據庫連接缺少必要的驅動,我們通過日誌查看確實是缺少部分數據庫的驅動,因爲DolphinScheduler默認只帶了Oracle和MySQL的驅動,並且需要將pom文件中的test模式去掉纔可以
鴻蒙原生應用再新丁!新華社 入局鴻蒙 來自 #HarmonyOS# 微博5月27日消息 #鴻蒙千帆起#新華社客戶端完成鴻蒙原生應用核心版本開發,將實現不同使用場景下更加智能、精準、及時的要聞推送,以及主流價值的全場景覆蓋和高效傳播!與此同
記一次攻防演練中幸運的從若依弱口令到後臺getshell的過程和分析。 0x01 漏洞發現 首先,我會先把目標的二級域名拿去使用搜索引擎來搜索收集到包含這個目標二級域名的三級域名或者四級域名的網站。 這樣子可以快速的定位到你所要測試的漏洞