2012-05-04 2 views
0

ListView에 최고 막대를 추가 할 수 있는지 알아 내려고했습니다. 어쩌면 높이가 20-50 픽셀이고 두 개의 버튼이있을 수 있습니다 (버튼도 클릭 할 수 있어야 함). 이미지 내 생각을 표현하기 :위의 30px 막대가있는 목록 뷰 변경?

enter image description here

맨 왼쪽 슛은 ListView 위의 바있다, 나는 이것을 달성 할 수 어쨌든 있나요?

+0

예, 일부 Button이있는 가로형 LinearLayout처럼 보입니다. 이미 해보고 문제가 있었습니까? – FoamyGuy

+0

그래서 목록보기가 없다고 말하고 있습니다. 예, 시도했지만 오류 메시지가 표시되지 않습니다. – TheBlueCat

+0

이미지의 왼쪽 부분을 참조하는 경우, 그것은'ActionBar' (기본 또는 사용자 정의 구현)입니다. – Luksprog

답변

3

현재 레이아웃을 모르므로 에 ListView 요소 만 있다고 가정합니다. 여기에 목록의 상단에 LinearLayoutButtons 3 인 :

<?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="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Button1" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Button2" /> 

     <Button 
      android:id="@+id/button3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Button3" /> 
    </LinearLayout> 

    <ListView 
     android:id="@+id/listView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 
    </ListView> 

</LinearLayout> 

나는 이것이 당신이 원하는 바랍니다.

+0

고맙습니다 :) 읽을 수있는 문서가 있습니까? 나는이 문제에 관심이 있으며 올바른 방향으로 나를 지적 할 수 있다면 감사 할 것입니다. – TheBlueCat

+0

이 코드를 시도 할 때 오류가 발생합니다. "텍스트 뷰의 리소스 ID를 제공해야합니다." 아니, 그 코드에서 텍스트보기가 없습니다. – TheBlueCat

+0

@TheBlueCat 위의 코드가 간단한 레이아웃이고, 목표에 의해 제한되기 때문에 추천할만한 문서는 없습니다 (예를 들어,'Buttons'로 가득 찬'LinearLayout'을'TableLayout'으로 대체하고 격자와 같은 레이아웃). 예를 들어, 이미지의 검은 색 막대는 1 개의 TextView ('layout_weight' 1)와 3 개의'ImageButtons' (그리기 가능 구분자 포함)로 구성됩니다. 'ActionBar'에 대한 많은 문서가 있습니다. – Luksprog

-1

사용이 :

listView.setDivider(getResources().getDrawable(R.drawable.list_view_divider)); 

list_view_divider은 당신이 원하는 높이의 투명 PNG 이미지되어야한다.

+0

감사합니다 :) 나는 그것을 시도 할 것입니다, 어떻게 onClickListener를 구현할 수 있습니까? 말해봐 : id.getDrawable(); id.setonClickListener? – TheBlueCat

+0

나는이 질문에 며칠 전에 대답했다. 이 Q & A를보십시오 : http://stackoverflow.com/questions/10417806/android-in-which-way-should-i-separate-code-from-style/10418109#10418109 –

+0

그 대답은 SQLLite에 관한 것입니까? 그게 내 질문에 어떻게 작용할까? 감사. – TheBlueCat

관련 문제