2011-09-13 4 views
0

비슷한 질문을 검색했지만 적절한 대답을 얻지 못하여 새로운 질문으로 게시했습니다.LinearLayout의 TextView 및 ListView

LinearLayout은 두 개의 TextViews과 하나의 목록보기를 가질 수 있습니까? 클래스가 ListActivity 인 경우에만 listview를 사용하여 배열 요소를 표시 할 수 있음을 알게되었습니다. 내 애플 리케이션의 클래스 활동을 확장하고 listView를 사용합니다.

IBM tutorial을 기반으로하는 RSS 리더를 구축하려고합니다. 프로젝트를 실행하면 두 텍스트보기 모두에서 구문 분석 된 텍스트가 표시되지만 ListView은 표시되지 않습니다. 필요한 경우 코드와 Logcat을 게시 할 수 있습니다.

+0

코드를 게시하면 문제가 해결됩니다. –

답변

1

어떤 활동에서든지 ListView을 가질 수 있습니다. ListActivity을 사용하면 평소보다 쉽게 ​​사용할 수 있습니다. 자세한 내용은 here을 참조하십시오.

0

당신은 예를 들어 내부의 다른보기와 목록보기와 선형 레이아웃을 가질 수 있습니다

?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:background="@drawable/background_new_search_activity_1"> 

<TextView 
      android:id="@+id/list_item_amount_text" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 

<ListView 
    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:cacheColorHint="#00000000"/> 

</LinearLayout> 

을 그리고 네 모든 활동에 ListView을 사용할 수 있습니다, ListActivity

3

을 확장 할 필요가 없습니다 선형 레이아웃은 여러 개의 자식을 가질 수 있습니다. ListActivity는 목록으로 구성된 활동을 처리 할 때 편의를 위해 Android가 추가 한 활동입니다.

일반 Activity에서 ListView를 사용할 수 있으며 모델의 데이터로 목록 항목을 채울 어댑터 만 구현하면됩니다.

Android에는 간단한 사용 사례에 사용할 수있는 기성품 어댑터가 있습니다. 물론 더 복잡한 beahviour가 필요한 경우 확장 할 수 있습니다.

어댑터 사용법을 더 잘 이해하려면 BaseAdapter, ArrayAdapterCursorAdapter을 확인하십시오.

0

ListView의 방향이 수직으로 설정되어 있는지 확인하십시오. 그렇지 않으면 모든 항목을 나란히 표시하려고 시도하며 사용 가능한보기 영역 밖에있는 항목은 표시되지 않습니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical"> <!-- << orientation setting here --> 
관련 문제