मैं एक बहुत ही आम समस्या का सामना कर रहा हूं: मैंने एक गतिविधि की घोषणा की और अब यह पता चला है कि इसके भीतर कुछ वस्तुओं को प्रदर्शित करना चाहिए ScrollView। ऐसा करने का सामान्य तरीका मौजूदा का उपयोग करना होगा ListAdapter, इसे एक ListViewऔर BOOM से कनेक्ट करना होगा जिसमें मेरे पास आइटमों की सूची होगी।
लेकिन आप एक नेस्टेड नहीं डालने चाहिए, ListViewएक में ScrollViewभी Android Lint इसके बारे में शिकायत - यह स्क्रॉल ऊपर शिकंजा के रूप में।
तो यहाँ मेरा सवाल है:
मैं कैसे ListAdapterएक LinearLayoutया कुछ इसी तरह से कनेक्ट करूं ?
मुझे पता है कि यह समाधान बहुत सी वस्तुओं के लिए नहीं होगा, लेकिन मेरी सूचियां बहुत कम हैं (<10 आइटम) इसलिए विचारों की पुन: स्थापना वास्तव में आवश्यक नहीं है। प्रदर्शन के लिहाज से मैं सभी विचारों को सीधे अंदर रख कर जी सकता हूं LinearLayout।
एक समाधान जो मैं अपने मौजूदा गतिविधि लेआउट को हेडर व्यू अनुभाग में रखना चाहूंगा ListView। लेकिन यह इस तंत्र को गाली देने जैसा लगता है इसलिए मैं एक क्लीनर समाधान की तलाश में हूं।
विचार?
अद्यतन: सही दिशा में प्रेरित करने के लिए मैं अपनी समस्या दिखाने के लिए एक नमूना लेआउट जोड़ता हूं:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/news_detail_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="visible">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/news_detail_layout_side_padding"
android:paddingRight="@dimen/news_detail_layout_side_padding"
android:paddingTop="@dimen/news_detail_layout_vertical_padding"
android:paddingBottom="@dimen/news_detail_layout_vertical_padding"
>
<TextView
android:id="@+id/news_detail_date"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal"
android:text="LALALA"
android:textSize="@dimen/news_detail_date_height"
android:textColor="@color/font_black"
/>
<Gallery
android:id="@+id/news_detail_image"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingTop="5dip"
android:paddingBottom="5dip"
/>
<TextView
android:id="@+id/news_detail_headline"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal"
android:text="Some awesome headline"
android:textSize="@dimen/news_detail_headline_height"
android:textColor="@color/font_black"
android:paddingTop="@dimen/news_detail_headline_paddingTop"
android:paddingBottom="@dimen/news_detail_headline_paddingBottom"
/>
<TextView
android:id="@+id/news_detail_content"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Here comes a lot of text so the scrollview is really needed."
android:textSize="@dimen/news_detail_content_height"
android:textColor="@color/font_black"
/>
<!---
HERE I NEED THE LIST OF ITEMS PROVIDED BY THE EXISTING ADAPTER.
They should be positioned at the end of the content, so making the scrollview smaller is not an option.
---->
</LinearLayout>
</ScrollView>
</LinearLayout>
अद्यतन 2 मैंने इसे समझने में आसान बनाने के लिए शीर्षक बदल दिया (एक डाउनवोट मिला, दोहा!)।