마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

리스트뷰 어댑터 관련 질문입니다.. !

0 추천
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">    
    <LinearLayout 
        android:id="@+id/upper_linear"
     android:layout_width="match_parent"
     android:layout_height="110dp"
     android:orientation="horizontal"
     android:background="@drawable/white_gray">    
     <ImageView 
         android:id="@+id/add_photo"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:background="@drawable/noimage1"
         android:clickable="true"/>
     <LinearLayout
         android:orientation="vertical"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:gravity="center_horizontal">         
         <LinearLayout 
             android:layout_width="match_parent"
             android:layout_height="wrap_content">
             <TextView 
                 android:id="@+id/p_textview1"
              android:layout_width="80dp"       
              android:layout_height="wrap_content"
              android:text="이름"/>
          <EditText 
              android:id="@+id/p_edittext1"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"   
              android:text="val"/>         
         </LinearLayout>                  
         <LinearLayout 
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
>
             <TextView 
                 android:id="@+id/p_textview2"
              android:layout_width="80dp"
              android:layout_height="wrap_content"
              android:text="전화번호"/>
          <EditText 
              android:id="@+id/p_edittext2"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="val"/>         
         </LinearLayout>              
     </LinearLayout>            
    </LinearLayout>   
    
 <LinearLayout 
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal"
     android:gravity="center_vertical"
     android:paddingBottom="8dp">
     <ImageView 
         android:id="@+id/list_deco1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerVertical="true"
         android:src="@drawable/pattern2"/>
     <LinearLayout 
      android:layout_width="125dp"
      android:layout_height="wrap_content"
      android:gravity="center_horizontal">
  <TextView
      android:id="@+id/header1"
      android:textSize="8pt"
      android:textColor="#ff595656"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"/>  
  </LinearLayout>
     <LinearLayout 
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:gravity="center_horizontal">
  <EditText
      android:id="@+id/val1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="12dp"
      android:layout_marginRight="12dp"
      android:singleLine="true"
      android:background="@drawable/line_drawable"/>
  </LinearLayout>
 </LinearLayout>
</RelativeLayout>

 

 

렐러티브레이아웃

ㄴ 리니어1

    ㄴ 내용

    ㄴ 내용

ㄴ 리니어2

    ㄴ 내용

    ㄴ 내용

 

이런식으로  xml을 짰는데요

리니어1은 한번만 나오고

리니어2는 자료의 양만큼 추가하는건 불가능한가요??

 

실행시켜보니 리니어1,2 전부 계속 반복되네요 ㅜㅜ

이럴땐 어떻게해야 2만 반복되게 할 수 있나요 ㅜㅜ??

 

 

 

++++++++++++++

8천자 이상안된데서 좀 줄였습니다!

 

리스트뷰에서 리니어1은 한번만 나오고

리니어 2는 자료양이 10개면 10번 자료와 함께 나오는 방법이 있나요??

어떻게 설명을 보충해야할까요 ㅜㅜ

익명사용자 님이 2015년 4월 27일 질문
2015년 4월 27일 수정

2개의 답변

0 추천
 
채택된 답변

https://github.com/susemi99/TestDBListView

같은 에제는 아니지만, 리스트뷰 에제예요.

 

https://github.com/susemi99/TestDBListView/blob/master/src/kr/mint/testdblistview/ListViewAdapter.java

이 파일의 getView()에 보면 

int resId = R.layout.list_item_person;
convertView = LayoutInflater.from(parent.getContext()).inflate(resId, null);

이런 코드가 있는데, 이게 한 row에 해당하는 레이아웃 파일을 가져오는 부분이에요.

만약 리니어1이나 2를 표시하려면 resId만 바꿔주면 되는거죠.

(물론 지금 짜놓은 코드에 따라 꽤 많이 바꿔줘야 할겁니다)

쎄미 (162,410 포인트) 님이 2015년 4월 27일 답변
그럼 조금만 더 연구해보고 사용한다면
한 화면에서 1은 한번 출력되고 2는 여러번 출력되는게 가능한거겠네요^^
감사합니다.
0 추천
설명을 이해할 수 있게해주시던지...

소스를 올려주시던지요..
콜벳 (7,150 포인트) 님이 2015년 4월 27일 답변
올렸어용 ㅋㅋ^^ㅜㅜ 잘봐주세용
이런 건 답변이 아니라 댓글로 달으심이...
...