सूचियों और पेजिंग की मदद से, डेटा को धीरे-धीरे लोड करना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
धीरे-धीरे लोड होने की सुविधा और पेजिंग की मदद से, अपने ऐप्लिकेशन में आइटम की बड़ी सूचियां दिखाई जा सकती हैं. इनमें अनलिमिटेड सूची भी शामिल है. इसके लिए, डेटा को धीरे-धीरे लोड करके दिखाया जाता है. इस टेक्नोलॉजी की मदद से, शुरुआती लोड होने में लगने वाले समय को कम किया जा सकता है. साथ ही, मेमोरी के इस्तेमाल को ऑप्टिमाइज़ करके परफ़ॉर्मेंस को बेहतर बनाया जा सकता है.
वर्शन के साथ काम करना
इसे लागू करने के लिए, ज़रूरी है कि आपके प्रोजेक्ट का minSDK एपीआई लेवल 21 या उससे ज़्यादा पर सेट हो.
डिपेंडेंसी
पेज वाला कॉन्टेंट दिखाना
पेजिंग लाइब्रेरी की मदद से, किसी बड़े डेटासेट के पेजों को लोड और दिखाया जा सकता है. यह डेटासेट, लोकल स्टोरेज या नेटवर्क से हासिल किया जाता है. पेज पर मौजूद सूची दिखाने के लिए, नीचे दिए गए कोड का इस्तेमाल करें. इस सूची में प्रोग्रेस बार दिखता है, ताकि उपयोगकर्ता को पता चल सके कि ज़्यादा डेटा फ़ेच किया जा रहा है:
LazyColumn: इस कॉम्पोज़ेबल का इस्तेमाल, आइटम (मैसेज) की बड़ी सूची को बेहतर तरीके से दिखाने के लिए किया जाता है. यह सिर्फ़ उन आइटम को रेंडर करता है जो स्क्रीन पर दिखते हैं. इससे संसाधन और मेमोरी बचती है.
lazyPagingItems ऑब्जेक्ट, LazyColumn में पेज किए गए डेटा को लोड करने और उसे बेहतर तरीके से दिखाने का काम करता है. यह LazyColumn कॉम्पोज़ेबल में, LazyPagingItems को items पर पास करता है.
MessageRow(message: Text), मैसेज के अलग-अलग आइटम को रेंडर करने के लिए ज़िम्मेदार है. ऐसा हो सकता है कि यह कार्ड में मैसेज भेजने वाले व्यक्ति और मैसेज का टेक्स्ट दिखाए.
MessagePlaceholder(), मैसेज का असल डेटा फ़ेच किए जाने के दौरान, विज़ुअल प्लेसहोल्डर (लोडिंग स्पिनर) दिखाता है. इससे उपयोगकर्ता अनुभव बेहतर होता है.
नतीजे
नीचे दिए गए वीडियो में, उपयोगकर्ता के स्क्रोल करने पर, बड़ी सूची से डेटा फ़ेच करने के नतीजे के व्यवहार को दिखाया गया है.
ऐसे संग्रह जिनमें यह गाइड शामिल है
यह गाइड, चुने गए क्विक गाइड के कलेक्शन का हिस्सा है. इसमें Android डेवलपमेंट के बड़े लक्ष्यों के बारे में बताया गया है:
सूची या ग्रिड दिखाना
सूचियों और ग्रिड की मदद से, आपके ऐप्लिकेशन में संग्रहों को ऐसे दिखाया जा सकता है कि वे उपयोगकर्ताओं को देखने में अच्छे लगें और उन्हें आसानी से समझ आएं.
जानें कि कॉम्पोज़ेबल फ़ंक्शन की मदद से, Material Design डिज़ाइन सिस्टम के आधार पर, आसानी से खूबसूरत यूज़र इंटरफ़ेस (यूआई) कॉम्पोनेंट कैसे बनाए जा सकते हैं.
इस वीडियो सीरीज़ में, Compose के अलग-अलग एपीआई के बारे में बताया गया है. इससे आपको यह जानने में मदद मिलेगी कि कौनसे एपीआई उपलब्ध हैं और उन्हें कैसे इस्तेमाल किया जा सकता है.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-02-06 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-02-06 (UTC) को अपडेट किया गया."],[],[],null,["# Lazily load data with lists and Paging\n\n\u003cbr /\u003e\n\nWith lazy loading and Paging, you can support large lists of items---including an\ninfinite list---in your app by loading and displaying data incrementally. This\ntechnique enables you to reduce initial load times and optimize memory usage,\nenhancing performance.\n| **Note:** For optimized performance, use the Paging Library with a lazy list for an infinite list of data.\n\nVersion compatibility\n---------------------\n\nThis implementation requires that your project minSDK be set to API level 21 or\nhigher.\n\n### Dependencies\n\n### Kotlin\n\n\u003cbr /\u003e\n\n```kotlin\n implementation(platform(\"androidx.compose:compose-bom:2025.08.00\"))\n implementation(\"androidx.paging:paging-compose:3.3.0-alpha05\")\n \n```\n\n\u003cbr /\u003e\n\n### Groovy\n\n\u003cbr /\u003e\n\n```groovy\n implementation platform('androidx.compose:compose-bom:2025.08.00')\n implementation \"androidx.paging:paging-compose:3.3.0-alpha05\"\n \n```\n\n\u003cbr /\u003e\n\nDisplay paged content\n---------------------\n\nWith the Paging library, you can load and display pages of data from a larger\ndataset acquired from local storage or over a network. Use the following code to\ndisplay a paginated list that shows a progress bar to indicate to the user that\nmore data is being fetched:\n\n\n```kotlin\n@Composable\nfun MessageList(\n modifier: Modifier,\n pager: Pager\u003cInt, Message\u003e\n) {\n val lazyPagingItems = pager.flow.collectAsLazyPagingItems()\n\n LazyColumn {\n items(\n lazyPagingItems.itemCount,\n key = lazyPagingItems.itemKey { it.id }\n ) { index -\u003e\n val message = lazyPagingItems[index]\n if (message != null) {\n MessageRow(message)\n } else {\n MessagePlaceholder()\n }\n }\n }\n @Composable\n fun MessagePlaceholder(modifier: Modifier) {\n Box(\n Modifier\n .fillMaxWidth()\n .height(48.dp)\n ) {\n CircularProgressIndicator()\n }\n }\n\n @Composable\n fun MessageRow(\n modifier: Modifier,\n message: Message\n ) {\n Card(modifier = Modifier.padding(8.dp)) {\n Column(\n modifier = Modifier.padding(8.dp),\n verticalArrangement = Arrangement.Center\n ) {\n Text(message.sender)\n Text(message.text)\n }\n }\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt#L760-L806\n```\n\n\u003cbr /\u003e\n\n### Key points about the code\n\n- [`LazyColumn`](/reference/kotlin/androidx/compose/foundation/lazy/package-summary#LazyColumn(androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.LazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,kotlin.Function1)): This composable is used to display a large list of items (messages) efficiently. It only renders the items that are visible on the screen, thus saving resources and memory.\n- The [`lazyPagingItems`](/reference/kotlin/androidx/paging/compose/LazyPagingItems) object efficiently manages the loading and presentation of paged data within the `LazyColumn`. It passes `LazyPagingItems` to [`items`](/reference/kotlin/androidx/compose/foundation/lazy/LazyListScope#items(kotlin.Int,kotlin.Function1,kotlin.Function1,kotlin.Function2)) in the `LazyColumn` composable.\n- `MessageRow(message: Text)` is responsible for rendering individual message items, likely displaying the sender and text of the message within a Card.\n- `MessagePlaceholder()` provides a visual placeholder (a loading spinner) while the actual message data is being fetched, enhancing the user experience.\n\nResults\n-------\n\nThe following video shows the resulting behavior of a large list fetching data\nas the user scrolls.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nCollections that contain this guide\n-----------------------------------\n\nThis guide is part of these curated Quick Guide collections that cover\nbroader Android development goals: \n\n### Display a list or grid\n\nLists and grids allow your app to display collections in a visually pleasing form that's easy for users to consume. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-a-list-or-grid) \n\n### Display interactive components\n\nLearn how composable functions can enable you to easily create beautiful UI components based on the Material Design design system. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-interactive-components) \n\n### Compose basics (video collection)\n\nThis series of videos introduces various Compose APIs, quickly showing you what's available and how to use them. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/compose-basics) \n\nHave questions or feedback\n--------------------------\n\nGo to our frequently asked questions page and learn about quick guides or reach out and let us know your thoughts. \n[Go to FAQ](/quick-guides/faq) [Leave feedback](https://issuetracker.google.com/issues/new?component=1573691&template=1993320)"]]