2015-01-22 3 views
-2

참고 : ListView를 사용하지 않기 때문에 ArrayAdapter가 실제로 적합하지 않다고 생각했습니다. RelativeLayout에 TextView를 사용하고 설명을 위해 ScrollView 내부에 다른 TextView를 배치했습니다.Android : 여러 TextViews가있는 상대적 레이아웃. 데이터를 바인딩하려면 어떤 종류의 어댑터를 사용해야합니까?

웹 서비스에서 데이터를 가져 와서이보기에 제목 및 설명을 표시하려고합니다. 어떤 종류의 어댑터를 사용해야합니까?

ArrayAdapter에 바인딩하는 것이 적합하지 않은 것처럼 보입니다. 그리고 CursorAdapter는 데이터베이스에서 데이터를 가져 오지 않기 때문에 적합하지 않습니다. 웹 서비스에서 데이터에 대한 AsyncTask를 수행 할 것입니다. 그리고 내 XML의 제목 및 정의 ID에 데이터를 바인딩하고 싶습니다.

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity$PlaceholderFragment"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="@string/title" 
     android:id="@+id/title"/> 

    <ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/scroll" 
     android:layout_below="@+id/title"> 

    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:id="@+id/definition" /> 
    </ScrollView> 

    <SearchView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/search" 
      android:layout_alignRight="@+id/title"/> 

</RelativeLayout> 
+1

'setText ("your text");'를 사용하여 데이터를 파싱하고 'TextView'로 텍스트를 설정해야합니다. – Gunaseelan

+1

어댑터는 AdapterView를 상속받은 클래스와 함께 작동합니다. RelativeLayout은 그렇지 않습니다. 수동으로 해봅시다. 왜 그런 간단한 작업을 위해 어댑터가 필요한가요? – Simas

답변

1

왜 어댑터입니까? 어댑터 - 어댑터 - 컬렉션의 뷰어가 필요로하는 인터페이스에 대한 인터페이스입니다. 당신은 그러한 뷰어를 갖고 있지 않은 것 같습니다.

+0

나는 안드로이드에서 어댑터를 잘 이해하지 못했습니다. 나는 전망을 직접적으로 업데이트하는 것에 앞서 갔다. –

관련 문제