SlideShare une entreprise Scribd logo
1  sur  8
Develop on Android
Android Lab Test
www.AndroidLabTest.com
Youku
By Bruno Delb
www.weibo.com/brunodelb
i.youku.com/brunodelb | www.weibo.com/brunodelb | blog.delb.cn
http://i.youku.com/brunoparis
Weibo
Officialsite
Lesson : The UI, the gallery (Gallery)
The UI, the gallery (Gallery)
• In this lesson, you will learn to create a gallery (Gallery)
of strings.
• For this, you will use the object Gallery and
ArrayAdapter.
The UI, the gallery (Gallery)
• Add a Gallery to the layout.
Gallery gallery = (Gallery)findViewById (R.id.gallery);
• To add strings to the Gallery, create an ArrayAdapter :
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
Main.this, // content
android.R.layout.simple_spinner_item, // layout provided by Android
new String[]{"One", "Two", "Three", ...} // items to add
);
The UI, the gallery (Gallery)
• To change the background color of the Gallery, use the method
setBackgroundColor().
gallery.setBackgroundColor(0xFF0000FF);
• To associate the ArrayAdapter to the Gallery, use the method setAdapter().
gallery.setAdapter(adapter);
Layout 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">
<Gallery
android:id="@+id/gallery"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
File Main.java
public class Main extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView (R.layout.main);
Gallery gallery = (Gallery)findViewById (R.id.gallery);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
Main.this,
android.R.layout.simple_spinner_item,
new String[]{"One", "Two",
"Three","Four","Five","Six","Seven","Eight","Nine","Ten"}
);
gallery.setBackgroundColor(0xFF0000FF);
gallery.setAdapter(adapter);
}
}
Test on your mobile
View_Gallery
Follow me on my channel PengYooTV …
On my Youku channel
http://i.youku.com/brunoparis
Who am I ?
Bruno Delb (www.delb.cn),
Author of the first french book of development of Java mobile application (2002),
Consultant, project manager and developer of social & mobile applications,
let’s talk about your needs ...
And on Weibo :
http://www.weibo.com/brunodelb

Contenu connexe

Plus de Bruno Delb

Android Lab Test : Using the sensor gyroscope (english)
Android Lab Test : Using the sensor gyroscope (english)Android Lab Test : Using the sensor gyroscope (english)
Android Lab Test : Using the sensor gyroscope (english)Bruno Delb
 
Android Lab Test : Using the network with HTTP (english)
Android Lab Test : Using the network with HTTP (english)Android Lab Test : Using the network with HTTP (english)
Android Lab Test : Using the network with HTTP (english)Bruno Delb
 
Android Lab Test : Managing sounds with SoundPool (english)
Android Lab Test : Managing sounds with SoundPool (english)Android Lab Test : Managing sounds with SoundPool (english)
Android Lab Test : Managing sounds with SoundPool (english)Bruno Delb
 
Android Lab Test : Using the text-to-speech (english)
Android Lab Test : Using the text-to-speech (english)Android Lab Test : Using the text-to-speech (english)
Android Lab Test : Using the text-to-speech (english)Bruno Delb
 
Android Lab Test : Reading the foot file list (english)
Android Lab Test : Reading the foot file list (english)Android Lab Test : Reading the foot file list (english)
Android Lab Test : Reading the foot file list (english)Bruno Delb
 
Android Lab Test : Creating a menu dynamically (english)
Android Lab Test : Creating a menu dynamically (english)Android Lab Test : Creating a menu dynamically (english)
Android Lab Test : Creating a menu dynamically (english)Bruno Delb
 
Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)Bruno Delb
 
Android Lab Test : The styles of views (english)
Android Lab Test : The styles of views (english)Android Lab Test : The styles of views (english)
Android Lab Test : The styles of views (english)Bruno Delb
 
Android Lab Test : Creating a menu context (english)
Android Lab Test : Creating a menu context (english)Android Lab Test : Creating a menu context (english)
Android Lab Test : Creating a menu context (english)Bruno Delb
 
Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)Bruno Delb
 
Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)Bruno Delb
 
Android Lab Test : Managing the telephone calls (english)
Android Lab Test : Managing the telephone calls (english)Android Lab Test : Managing the telephone calls (english)
Android Lab Test : Managing the telephone calls (english)Bruno Delb
 
Android Lab Test : Reading the SMS-inbox (english)
Android Lab Test : Reading the SMS-inbox (english)Android Lab Test : Reading the SMS-inbox (english)
Android Lab Test : Reading the SMS-inbox (english)Bruno Delb
 
Android Lab Test : Installation of application in Java (english)
Android Lab Test : Installation of application in Java (english)Android Lab Test : Installation of application in Java (english)
Android Lab Test : Installation of application in Java (english)Bruno Delb
 
Android Lab Test : Ecrire un texte sur le canevas (français)
Android Lab Test : Ecrire un texte sur le canevas (français)Android Lab Test : Ecrire un texte sur le canevas (français)
Android Lab Test : Ecrire un texte sur le canevas (français)Bruno Delb
 
Android Lab Test : La connectivité réseau avec HTTP (français)
Android Lab Test : La connectivité réseau avec HTTP (français)Android Lab Test : La connectivité réseau avec HTTP (français)
Android Lab Test : La connectivité réseau avec HTTP (français)Bruno Delb
 
Android Lab Test : Le capteur gyroscope (français)
Android Lab Test : Le capteur gyroscope (français)Android Lab Test : Le capteur gyroscope (français)
Android Lab Test : Le capteur gyroscope (français)Bruno Delb
 
Android Lab Test : Les threads (français)
Android Lab Test : Les threads (français)Android Lab Test : Les threads (français)
Android Lab Test : Les threads (français)Bruno Delb
 
Android Lab Test : L'installation d'une application en Java (français)
Android Lab Test : L'installation d'une application en Java (français)Android Lab Test : L'installation d'une application en Java (français)
Android Lab Test : L'installation d'une application en Java (français)Bruno Delb
 
Android Lab Test : Le stockage avec SharedPreferences (français)
Android Lab Test : Le stockage avec SharedPreferences (français)Android Lab Test : Le stockage avec SharedPreferences (français)
Android Lab Test : Le stockage avec SharedPreferences (français)Bruno Delb
 

Plus de Bruno Delb (20)

Android Lab Test : Using the sensor gyroscope (english)
Android Lab Test : Using the sensor gyroscope (english)Android Lab Test : Using the sensor gyroscope (english)
Android Lab Test : Using the sensor gyroscope (english)
 
Android Lab Test : Using the network with HTTP (english)
Android Lab Test : Using the network with HTTP (english)Android Lab Test : Using the network with HTTP (english)
Android Lab Test : Using the network with HTTP (english)
 
Android Lab Test : Managing sounds with SoundPool (english)
Android Lab Test : Managing sounds with SoundPool (english)Android Lab Test : Managing sounds with SoundPool (english)
Android Lab Test : Managing sounds with SoundPool (english)
 
Android Lab Test : Using the text-to-speech (english)
Android Lab Test : Using the text-to-speech (english)Android Lab Test : Using the text-to-speech (english)
Android Lab Test : Using the text-to-speech (english)
 
Android Lab Test : Reading the foot file list (english)
Android Lab Test : Reading the foot file list (english)Android Lab Test : Reading the foot file list (english)
Android Lab Test : Reading the foot file list (english)
 
Android Lab Test : Creating a menu dynamically (english)
Android Lab Test : Creating a menu dynamically (english)Android Lab Test : Creating a menu dynamically (english)
Android Lab Test : Creating a menu dynamically (english)
 
Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)
 
Android Lab Test : The styles of views (english)
Android Lab Test : The styles of views (english)Android Lab Test : The styles of views (english)
Android Lab Test : The styles of views (english)
 
Android Lab Test : Creating a menu context (english)
Android Lab Test : Creating a menu context (english)Android Lab Test : Creating a menu context (english)
Android Lab Test : Creating a menu context (english)
 
Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)
 
Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)
 
Android Lab Test : Managing the telephone calls (english)
Android Lab Test : Managing the telephone calls (english)Android Lab Test : Managing the telephone calls (english)
Android Lab Test : Managing the telephone calls (english)
 
Android Lab Test : Reading the SMS-inbox (english)
Android Lab Test : Reading the SMS-inbox (english)Android Lab Test : Reading the SMS-inbox (english)
Android Lab Test : Reading the SMS-inbox (english)
 
Android Lab Test : Installation of application in Java (english)
Android Lab Test : Installation of application in Java (english)Android Lab Test : Installation of application in Java (english)
Android Lab Test : Installation of application in Java (english)
 
Android Lab Test : Ecrire un texte sur le canevas (français)
Android Lab Test : Ecrire un texte sur le canevas (français)Android Lab Test : Ecrire un texte sur le canevas (français)
Android Lab Test : Ecrire un texte sur le canevas (français)
 
Android Lab Test : La connectivité réseau avec HTTP (français)
Android Lab Test : La connectivité réseau avec HTTP (français)Android Lab Test : La connectivité réseau avec HTTP (français)
Android Lab Test : La connectivité réseau avec HTTP (français)
 
Android Lab Test : Le capteur gyroscope (français)
Android Lab Test : Le capteur gyroscope (français)Android Lab Test : Le capteur gyroscope (français)
Android Lab Test : Le capteur gyroscope (français)
 
Android Lab Test : Les threads (français)
Android Lab Test : Les threads (français)Android Lab Test : Les threads (français)
Android Lab Test : Les threads (français)
 
Android Lab Test : L'installation d'une application en Java (français)
Android Lab Test : L'installation d'une application en Java (français)Android Lab Test : L'installation d'une application en Java (français)
Android Lab Test : L'installation d'une application en Java (français)
 
Android Lab Test : Le stockage avec SharedPreferences (français)
Android Lab Test : Le stockage avec SharedPreferences (français)Android Lab Test : Le stockage avec SharedPreferences (français)
Android Lab Test : Le stockage avec SharedPreferences (français)
 

Dernier

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 

Dernier (20)

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 

Android Lab Test : The views, the Gallery (english)

  • 1. Develop on Android Android Lab Test www.AndroidLabTest.com Youku By Bruno Delb www.weibo.com/brunodelb i.youku.com/brunodelb | www.weibo.com/brunodelb | blog.delb.cn http://i.youku.com/brunoparis Weibo Officialsite Lesson : The UI, the gallery (Gallery)
  • 2. The UI, the gallery (Gallery) • In this lesson, you will learn to create a gallery (Gallery) of strings. • For this, you will use the object Gallery and ArrayAdapter.
  • 3. The UI, the gallery (Gallery) • Add a Gallery to the layout. Gallery gallery = (Gallery)findViewById (R.id.gallery); • To add strings to the Gallery, create an ArrayAdapter : ArrayAdapter<String> adapter = new ArrayAdapter<String>( Main.this, // content android.R.layout.simple_spinner_item, // layout provided by Android new String[]{"One", "Two", "Three", ...} // items to add );
  • 4. The UI, the gallery (Gallery) • To change the background color of the Gallery, use the method setBackgroundColor(). gallery.setBackgroundColor(0xFF0000FF); • To associate the ArrayAdapter to the Gallery, use the method setAdapter(). gallery.setAdapter(adapter);
  • 5. Layout 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"> <Gallery android:id="@+id/gallery" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>
  • 6. File Main.java public class Main extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView (R.layout.main); Gallery gallery = (Gallery)findViewById (R.id.gallery); ArrayAdapter<String> adapter = new ArrayAdapter<String>( Main.this, android.R.layout.simple_spinner_item, new String[]{"One", "Two", "Three","Four","Five","Six","Seven","Eight","Nine","Ten"} ); gallery.setBackgroundColor(0xFF0000FF); gallery.setAdapter(adapter); } }
  • 7. Test on your mobile View_Gallery
  • 8. Follow me on my channel PengYooTV … On my Youku channel http://i.youku.com/brunoparis Who am I ? Bruno Delb (www.delb.cn), Author of the first french book of development of Java mobile application (2002), Consultant, project manager and developer of social & mobile applications, let’s talk about your needs ... And on Weibo : http://www.weibo.com/brunodelb