2012-07-10 8 views
0

내 응용 프로그램에서 나는 listview.List보기에서 데이터베이스의 데이터를 보여주는 것처럼 2 columns.Now이 열 사이의 가로줄을 그리는 2 열을 구분하는 디스플레이가 있어야합니다. 도와주세요. 미리 감사드립니다.Divider in listview

답변

1

당신은 사이 textViews 수평 분할 사용하기 때문에

이 코드

 <View 
      android:id="@+id/View01" 
      android:layout_width="fill_parent" 
      android:layout_height="2dp" 
      android:background="#2B497B" 
     /> 
이 수평 및 수직 뷰를 사용하여 목록 XML 파일에서 목록보기 항목을 표시하기위한 별도의 XML 파일을 관리해야

및 수직 분할을위한

  <View 
      android:id="@+id/View02" 
      android:layout_width="2dip" 
      android:layout_height="fill_parent" 
      android:background="#2B497B" 
     /> 

행운

+1

,하지만 만약 내가 수직 분배기를 사용하면 아무 것도 보여주지 않는다. – Prakash

0

enter image description here

당신이 당신의 목록보기를 정의하는 XML 파일에서
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="horizontal" > 


<LinearLayout 
     android:layout_weight="0.3" 
     android:orientation="vertical" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent"> 

     <TextView 
      android:padding="2dp" 
      android:id="@+id/nameedit" 
      android:textSize="15dp" 
      android:layout_height="40dp" 
      android:layout_width="fill_parent" 
      android:layout_gravity="center" 
      android:text="@string/search"> 
     </EditText> 
     <View 
      android:id="@+id/View01" 
      android:layout_width="fill_parent" 
      android:layout_height="2dp" 
      android:background="#2B497B" 
     /> 
<TextView 
      android:id="@+id/header" 
      android:layout_height="40dp" 
      android:layout_width="fill_parent" 
      android:textColor="#fff" 
      android:textSize="15dp" 
      android:gravity="center" 
      android:text="@string/reports"/> 
     <!-- <ListView android:id="@+id/namelist" 
     android:cacheColorHint="#00000000" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:fadingEdge="none"> 
     </ListView> --> 

    </LinearLayout> 
    <View 
      android:id="@+id/View02" 
      android:layout_width="2dip" 
      android:layout_height="fill_parent" 
      android:background="#2B497B" 
     /> 

    <LinearLayout 
     android:layout_weight="0.7" 
     android:orientation="vertical" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent"> 

     <TextView 
      android:id="@+id/header" 
      android:layout_height="40dp" 
      android:layout_width="fill_parent" 
      android:textColor="#fff" 
      android:textSize="15dp" 
      android:gravity="center" 
      android:text="@string/reports"/> 
     <View 
      android:id="@+id/View03" 
      android:layout_width="fill_parent" 
      android:layout_height="2dp" 
      android:background="#2B497B" 
     /> 

     <!-- <ListView android:id="@+id/reportslist" 
     android:cacheColorHint="#00000000" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:fadingEdge="none"/> --> 
     <TextView 
      android:id="@+id/header" 
      android:layout_height="40dp" 
      android:layout_width="fill_parent" 
      android:textColor="#fff" 
      android:textSize="15dp" 
      android:gravity="center" 
      android:text="@string/reports"/> 

    </LinearLayout> 

0

는, 디바이더 높이에 대한 또 하나 개의 매개 변수를 추가 : 여기

 <ListView 
      android:layout_marginTop="10dip" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:divider="@color/listDivider" 
      android:dividerHeight="1dp" 
      android:footerDividersEnabled="false" 
      android:headerDividersEnabled="true" 
      style="@style/listBackground" 
      android:id="@+id/list"/> 

는 "listBackground는"사용자 정의 배경입니다 내 style.xml 파일에 정의한. 그리고 "listDivider는"이 같은 내 color.xml에서 정의한 분할의 색상입니다 : 내가 가로보기 위해 시도하는 경우는 두 개의 텍스트 뷰 사이에 선을 shpws 당신의 code.In 위해 노력

 <color name="listDivider">#cfcfcf</color> 
+0

감사합니다. Yogesh Somani. 그것의 수평으로 나눕니다,하지만 난 수직으로 – Prakash

+0

잘 나누기를 원한다면, listitem을위한 xml 파일을 만들어야합니다. (버튼, textviews 등과 같은 것들을 많이 포함하고있을 것입니다.) 그리고이 xml 파일을 팽창시킵니다. 목록보기로. 이 xml 파일에서는 Ram Kiran이 수행 한 것처럼 height = fill_parent 및 width = 1 dip으로보기 (필요한 경우)를 정의합니다. 그것은 수직선을 그릴 것입니다. –