Android Application Development Cookbook: 93 Recipes for Building Winning Apps



Download 32,34 Mb.
Pdf ko'rish
bet52/56
Sana26.02.2022
Hajmi32,34 Mb.
#470540
1   ...   48   49   50   51   52   53   54   55   56
Bog'liq
Android Application Development Cookbook

54

ChAPter 2
using Views to design the user interFAce
for (int i = 1; i <= tag; i++) {
star = (CheckBox) rating.findViewWithTag(String.valueOf(i));
star.setChecked(true);
}
//---uncheck all remaining stars---
for (int i = tag + 1; i <= 5; i++) {
star = (CheckBox) rating.findViewWithTag(String.valueOf(i));
star.setChecked(false);
}
}
};
}
Here, you first locate all five checkboxes and listen to each checkbox’s 
onClick()
event. You locate 
the individual checkboxes using the 
findViewWithTag()
method of the 
LinearLayout
instance 
(because the checkboxes are all embedded within a 
LinearLayout
). 
When a checkbox is tapped, you check all the checkboxes up to the checkbox that was tapped and 
uncheck all the checkboxes thereafter. 
Figure 2-9 shows the star rating system in action. 
Figure 2-9 
www.it-ebooks.info


 
Recipe 2.6 using AutocompleteTextView

55
reCiPe 2.6 
using AutoCoMPLetetextvieW
Android Versions
Level 1 and above
permissions
None
source code to download from Wrox.com
AutoComplete.zip
While you can use an 
EditText
view for entering text, it is sometimes useful to provide users 
with suggestions to automatically complete what they are typing. For example, if a user is typing 
a search string into an 
EditText
, you can offer possible suggestions to complete the search string 
while the user is typing. In this case, you can use the 
AutoCompleteTextView
to do so. This recipe 
shows you how.
solution
The 
AutoCompleteTextView
is an editable text view that shows completion suggestions while the 
user is typing. The suggestions are displayed as a drop-down menu that contains content that is sup-
plied by you. 
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:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name of President" />
android:id="@+id/txtCountries"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

www.it-ebooks.info



Download 32,34 Mb.

Do'stlaringiz bilan baham:
1   ...   48   49   50   51   52   53   54   55   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