일부 클릭 후 뉴스 콘텐츠가있는 활동이 표시됩니다. 그 밑에는 비동기 작업에 동적으로로드되는 주석을 표시하고 싶습니다.프로그래밍 방식으로 (선형) 레이아웃 안에 뷰를 추가합니다 (즉, ScrollView 내부에 있음)
한 가지 방법은 ListView 및 사용자 지정 ArrayAdapter를 사용하는 것이지만 목록 뷰의 높이를 수동으로 무시하는 경우에도 ListView를 ScrollView 안에 넣어야합니다. 목록 항목 하나와 그 중 하나를 표시합니다.
다른 접근법은 LinearLayout을 주석 홀더로 정의하는 것입니다. 자체 XML 파일에 정의 된 다른 LinearLayouts를 부 풀리고 내용을 채우고 소유자의보기에 첨부합니다. 그것은 뉴스의 내용 아래에 주석을 푸시한다는 점을 제외하면 프로그램의 관점에서 보면 잘 작동합니다. 뉴스의 내용 (뉴스의 내용이 겹치는 부분) 아래에 댓글의 스크롤 가능한 다른보기가 만들어집니다.
목록과 관련이없는 다른 방법이 있습니까, 아니면 어떻게 다른 접근 방식을 사용할 수 있습니까?
뉴스 컨텐츠를 보유하고 XML 레이아웃에서 관련 코드는 다음과 같습니다
<LinearLayout> //global layout
<LinearLayout>
//views that hold title, date, content
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/commentsHolder"
android:orientation="vertical">
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#ed1b24"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="KOMENTARI"
android:layout_marginLeft="5dp"/>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#ed1b24"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:orientation="vertical"
android:id="@+id/comments_holder_view"
android:layout_weight="1">
</LinearLayout>
</LinearLayout>
</LinearLayout>
하나의 코멘트에 해당하는 코드입니다
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/comments_holder_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="@+id/comment_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/comments_back_details"
android:text="Ovde ide tekst komentara, koji se, naravno, dinamicki dodaje."/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/comment_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/categoryStyle"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
style="@style/categoryStyle"
/>
<TextView
android:id="@+id/comment_pubdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/categoryStyle"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:orientation="horizontal"
android:layout_margin="5dp"
android:background="#d1d1d1">
</LinearLayout>
어떤 주셔서 대단히 감사합니다 댓글. 이것은 나를 위해 매우 중요합니다.
당신의 활동에서'getLayoutInflater(). inflate (R.layout.comment, null);'를 사용합니다. – njzk2
Ovidiu를 게시 한 것과 똑같이했는데, 잘 작동하지만 어떻게 든 그 선형 레이아웃 (id가 comments_holder_vie 인 w)는 다른 레이아웃에 속합니다. 정적으로 (수동으로) 여러 주석 레이아웃을 포함하면 모든 것이 잘 표시됩니다. 이러한보기를 동적으로 추가 할 때 문제가 나타나는 것으로 보입니다. 그래도 고맙습니다. – Dimmy3
추가 된 의견 (의견)을 만드는 방법에 대한 몇 가지 코드를 게시하십시오. –