Android Application Development Cookbook: 93 Recipes for Building Winning Apps



Download 32,34 Mb.
Pdf ko'rish
bet49/56
Sana26.02.2022
Hajmi32,34 Mb.
#470540
1   ...   45   46   47   48   49   50   51   52   ...   56
Bog'liq
Android Application Development Cookbook

 
Recipe 2.4 using checkBoxes

49
Figure 2-6 
reCiPe 2.4 
using CheCKboxes
Android Versions
Level 1 and above
permissions
None
source code to download from Wrox.com
CheckBoxes.zip
Like radio buttons, checkboxes enable users to select one or more options from a list. A 
CheckBox
has two states: checked or unchecked. Unlike radio buttons, checkboxes can be checked and 
unchecked by the user without regard to the state of other checkboxes. This recipe shows how to use 
checkboxes in your Android application. 
www.it-ebooks.info


50

ChAPter 2
using Views to design the user interFAce
solution
Assume you have the following code snippet in the 
activity_main.xml
file: 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:id="@+id/chkAutosave"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Autosave" />
android:id="@+id/star"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

The 
CheckBox
element defines an item for users to check or uncheck. Android supports a special 
type of checkbox known as the star checkbox. You display a star checkbox by setting the 
style
attribute and setting its value to 
?android:attr/starStyle
.
Figure 2-7 shows the default checkbox and the star checkbox. The top part shows the unchecked 
state of the two checkboxes, and the lower portion shows the checked state.
The following code snippet shows how to determine whether a checkbox is 
checked:
package net.learn2develop.checkboxes;
import android.app.Activity;
import android.os.Bundle;

Download 32,34 Mb.

Do'stlaringiz bilan baham:
1   ...   45   46   47   48   49   50   51   52   ...   56




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish