2011-01-03 5 views
5

안드로이드 프로그래밍에서 모든, 첫 번째 게시물과 멍청한 놈,하지만 배우려는 의지! 기본적으로 탭 레이아웃의 Google 샘플을 가져 왔습니다. here안드로이드 탭 레이아웃 단락에서 라인 디바이더 만들기

그 방법은 각 탭 내에서 텍스트가있는 탭을 만드는 것이 매우 쉽지만 탭을 선택하면 만들려고합니다. 아래에 나열된 텍스트를 구분선으로 구분하고 싶습니다. 그래서 한 줄이 각 단락마다 나뉘어 지지만, 나는 이것을하는 데 어려움을 겪고 있습니다. main.xml에 :

public class HelloTabWidget extends TabActivity { 

    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     TabHost mTabHost = getTabHost(); 

mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(R.id.textview1));  
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(R.id.textview2)); 
mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(R.id.textview3)); 
mTabHost.addTab(mTabHost.newTabSpec("tab_test4").setIndicator("TAB 4").setContent(R.id.textview4)); 
     mTabHost.setCurrentTab(0); 
    } 
} 
: 자바 파일의 정보가

<?xml version="1.0" encoding="utf-8"?> 

 <TableRow> 
      <TextView 
      android:id="@+id/textview1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="this is the FIRST line of the 1st tab" /> 
      <TextView 
      android:id="@+id/textview1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="this is the SECOND line of the 1st tab" /> 
      </TableRow> 
      <View 
    android:layout_height="2dip" 
    android:background="#FF909090" /> 

    <TableRow> 
     <TextView 
      android:id="@+id/textview2" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="this is First line of the 2nd tab" /> 
      </TableRow> 
      <View 
    android:layout_height="2dip" 
    android:background="#FF909090" /> 
      <View 
    android:layout_height="2dip" 
    android:background="#FF909090" /> 
     <TextView 
      android:id="@+id/textview3" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="this is the First line of the 3rd tab" /> 
     <TextView 
      android:id="@+id/textview4" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="This is the First line of the 4th tab." /> 

      </TableLayout> 
    </FrameLayout> 
여기

입니다 이것은 내가 지금까지 무엇을 가지고

main.xml에서 첫 번째 줄에는 "이것은 첫 번째 탭의 첫 번째 줄"이지만 "첫 번째 줄의 두 번째 줄"입니다. 첫 줄에는 다른 줄의 탭이 표시됩니다. . 사전에 도움을 주셔서 감사 드리며, 장래에 다른 사람들을 도울 수 있기를 희망합니다.

답변

23

구분 기호 (영역을 두 섹션으로 나누는 선) 만 있으면 레이아웃 XML 파일에 다음 코드를 사용할 수 있습니다.

<View android:id="@+id/firstDivider" 
     android:layout_height="2dp" 
     android:layout_width="fill_parent" 
     android:background="#000080" /> 

위의 코드는 2dp 두께의 청색 구분선을 생성합니다. layout_height을 늘리면 분배기의 두께가 증가합니다.

모든 검색어에 대해 되돌리기.

+0

매우 빠른 답변 주셔서 감사합니다. 그러나 제공 한 코드는 제가 가지고있는 것과 거의 같습니다. 내가하려는 것은 각 탭 아래에 텍스트를 놓고, 별도의 단락에서 원하는 각 탭 아래의 텍스트를 삽입하고, 각 단락 사이에 나는 한 줄을 가고 싶습니다. <텍스트 뷰 안드로이드 : 지금까지 나는이 수행하여 별도의 단락에서 텍스트를 넣을 수 있었다 ID를 = "@ + ID/textview1" 안드로이드 : layout_width = "fill_parent" 안드로이드 : layout_height = "fill_parent" 안드로이드 : text = "첫 번째 탭의 첫 번째 줄입니다 \ n 두 번째 탭의 두 번째 줄입니다"/> – Clozecall

+0

\ n을 사용하면 각 탭 내에 새 단락이 만들어 지지만 두 개 이상의 단락과 줄 바꿈이 필요합니다. 각각. -감사. – Clozecall

+0

@ mudassir : 자바 코드를 통해 구분선을 만들 수 있습니까? 그렇다면 어떻게? 그 긴급한 대답을 부탁합니다 – Shruti