Skip to content

niyati10000/ArrayAdapter-Dynamic-Dropdowns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📱 Dynamic Spinner & ArrayAdapter Demo

A hands-on Android project designed to teach students how to use the ArrayAdapter class to create dependent Dropdown menus (Spinners).

📖 Overview

This application mimics a simplified E-commerce filter. It demonstrates the logic of "Cascading Selectors":

  1. User selects a Brand (e.g., Samsung).
  2. App detects the selection via a Listener.
  3. App dynamically updates the second dropdown to show only relevant models (e.g., S24, S23).

🎓 Key Concepts Covered

By studying this code, students will learn:

  • ArrayAdapter: How to bridge data from strings.xml to UI components.
  • Android Resources: Organizing static data in res/values/strings.xml using <string-array>.
  • Event Handling: Implementing OnItemSelectedListener to trigger actions.
  • Conditional Logic: Switching adapters based on array index positions.

📂 Project Logic

1. Data Source (strings.xml)

We store the data in static arrays to keep the Java code clean.

<string-array name="Mobile">
    <item>Apple</item>
    <item>Samsung</item>
</string-array>

<string-array name="apple">
    <item>iPhone 15</item>
    <item>iPhone 14</item>
</string-array>

About

A beginner-friendly Android project demonstrating how to use ArrayAdapter to link strings.xml arrays to Spinners. Shows how to create dependent dropdowns (Brand → Model) using Java.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages