Generate a prompt for an Auto Image Slider using the latest Material UI Design, with an item click that opens a new Activity in Kotlin in Android Studio.
Create a complete, modern **Auto Image Slider Android application** using **Kotlin** in **Android Studio**, following the latest **Material Design / Material 3 UI guidelines**.
### 1. Technology Requirements
* Programming Language: **Kotlin**
* IDE: **Android Studio**
* UI: **Material 3 / latest Material UI**
* Use **ViewBinding**.
* Use **RecyclerView or ViewPager2** for the image slider.
* Use **Glide or Coil** for efficient image loading.
* Follow modern Android development best practices.
* Code must be clean, modular, readable, and production-ready.
* Avoid deprecated Android APIs wherever possible.
### 2. Home Screen – Auto Image Slider
Create a beautiful Home Activity containing an automatic image slider at the top.
Requirements:
* Use **ViewPager2** for horizontal image sliding.
* Display multiple promotional/banner images.
* Automatically change the image every **3 seconds**.
* Provide smooth slide animations.
* Allow the user to manually swipe left/right.
* Pause or handle auto-sliding appropriately when the Activity is not visible.
* Resume automatic sliding when the Activity becomes visible again.
* Add **page indicators/dots** below the slider.
* Highlight the currently selected image.
* Use rounded corners with a modern Material 3 appearance.
* Add proper margins and spacing.
* Make the slider responsive for different screen sizes.
### 3. Image Click Listener
Every slider item must be clickable.
When the user taps an image:
```text
Slider Image
↓
Item Click
↓
Open New Activity
```
Each image should have its own associated data, such as:
* Image resource
* Title
* Description
* ID or unique identifier
When an image is clicked, open a separate **DetailActivity** using an Intent.
Pass the selected item's information from the Home Activity to DetailActivity using Intent extras.
Example:
```kotlin
val intent = Intent(this, DetailActivity::class.java)
intent.putExtra("ITEM_ID", item.id)
intent.putExtra("ITEM_TITLE", item.title)
startActivity(intent)
```
### 4. Detail Activity
Create a modern **DetailActivity** using Material 3 design.
Display:
* Selected image
* Title
* Description
* Optional action button
* Material 3 TopAppBar
* Back navigation
The DetailActivity must display the exact content associated with the image that the user selected.
### 5. UI Design
Create a premium, clean, modern interface.
Use:
* Material 3 CardView / Card
* Rounded corners
* Proper elevation
* Material 3 buttons
* Modern typography
* Consistent padding
* Light background
* Responsive layouts
* Edge-to-edge layout where appropriate
The slider should look similar to a professional modern Android application rather than a basic tutorial project.
### 6. Suggested Project Structure
Organize the project cleanly:
```text
app/
├── data/
│ └── SliderItem.kt
│
├── adapter/
│ └── SliderAdapter.kt
│
├── ui/
│ ├── HomeActivity.kt
│ └── DetailActivity.kt
│
├── res/
│ ├── drawable/
│ ├── layout/
│ │ ├── activity_home.xml
│ │ ├── activity_detail.xml
│ │ └── item_slider.xml
│ └── values/
│
└── AndroidManifest.xml
```
### 7. Slider Data Model
Create a Kotlin data class similar to:
```kotlin
data class SliderItem(
val id: Int,
val imageResId: Int,
val title: String,
val description: String
)
```
Create at least **5 sample slider items** using drawable resources.
### 8. Adapter
Create a dedicated `SliderAdapter` for ViewPager2.
The adapter should:
* Bind slider images.
* Bind required text/data.
* Handle item click events.
* Use ViewBinding.
* Avoid memory leaks.
* Follow RecyclerView/ViewPager2 best practices.
Use a lambda/callback approach for click handling, for example:
```kotlin
SliderAdapter(items) { selectedItem ->
// Open DetailActivity
}
```
### 9. Automatic Sliding
Implement automatic sliding using a lifecycle-aware approach.
Requirements:
* Change slides every 3 seconds.
* Stop automatic sliding when the Activity is paused/stopped.
* Resume when the Activity becomes active.
* Prevent multiple handlers/jobs from running simultaneously.
* Avoid crashes when the Activity is destroyed.
* Handle the last slide correctly.
Prefer a modern coroutine/lifecycle-based implementation where appropriate.
### 10. Page Indicator
Add a page indicator below ViewPager2.
Example:
```text
● ○ ○ ○ ○
```
The indicator must update automatically whenever the user changes the slide manually or when the automatic slider changes the page.
### 11. XML Layout
Create complete XML layouts with:
* Material 3 compatible components
* ConstraintLayout or another suitable modern layout
* ShapeableImageView or ImageView with rounded corners
* ViewPager2
* Page indicator
* Material 3 Card
* Proper accessibility attributes
The slider image should use:
```xml
android:scaleType="centerCrop"
```
where appropriate.
### 12. Android Manifest
Configure both Activities correctly:
```xml
<activity
android:name=".ui.DetailActivity" />
<activity
android:name=".ui.HomeActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
```
### 13. Important Requirements
Make the project **fully functional and buildable**.
Provide:
1. Complete `build.gradle.kts` configuration.
2. Complete `AndroidManifest.xml`.
3. `HomeActivity.kt`.
4. `DetailActivity.kt`.
5. `SliderItem.kt`.
6. `SliderAdapter.kt`.
7. `activity_home.xml`.
8. `activity_detail.xml`.
9. `item_slider.xml`.
10. Required drawable/background resources.
11. Required Material 3 theme configuration.
12. Required dependencies.
13. Any required imports.
14. Step-by-step instructions explaining where every file should be placed.
Do not provide pseudo-code or incomplete snippets.
### 14. Error Prevention
Before providing the final code, verify that:
* All imports are correct.
* IDs referenced in Kotlin exist in XML.
* Package names are consistent.
* ViewBinding names are correct.
* ViewPager2 is configured correctly.
* The Intent correctly opens DetailActivity.
* Intent extras use matching keys and data types.
* Auto-sliding does not continue after the Activity is destroyed.
* No deprecated APIs are unnecessarily used.
* The project can compile in the latest stable Android Studio environment.
### Final Goal
The final application should provide this complete user experience:
**Home Activity**
→ Modern Material 3 UI
→ Automatic Image Slider
→ 3-second auto-slide
→ Manual swipe
→ Page indicators
→ Click any image
→ Open corresponding DetailActivity
→ Display selected image, title, and description
→ Material 3 Back navigation
Make the final implementation **professional, responsive, maintainable, and ready to run in Android Studio**.