2013-10-06 2 views
0

저는 처음부터 ListView를 처음 접했습니다.ListActivity에서 안드로이드 고정 헤더

어쨌든, 내가하고 싶은 것은 프로그래밍 방식으로 그리고 하나의 xml 파일만으로 작성되는 내 목록 위에 버튼이나 기타를 들고있는 것이 분명합니다. XML 파일 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/LinearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    tools:context=".Main" > 


    <ImageView 
     android:id="@+id/picID" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingBottom="10dp" 
     android:paddingRight="10dp" 
     android:paddingTop="10dp" /> 

    <LinearLayout 
     android:id="@+id/LinearLayout2" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/eventName" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="18sp" /> 

     <TextView 
      android:id="@+id/eventTime" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="right" 
      android:layout_marginRight="5dp" 
      android:textSize="16sp" /> 
    </LinearLayout> 

</LinearLayout> 

그런 다음 Main.java에 단순히

SimpleAdapter adapter = new SimpleAdapter(Main.this, fillMaps, 
        R.layout.main, from, to); 
      setListAdapter(adapter); 

그래서 기본적으로 내가 XML 파일에 <ListView/>이없는 내 ListAdapter 정의합니다.

+0

나는 당신이 원하는대로 분명하지 않습니다. 귀하의 활동 또는 사용자 정의 listview 상단에 고정 버튼? –

+0

@RohanKandwal 불명확 함을 드려서 죄송합니다. 상단에 버튼을 고정시키고 싶습니다. 즉 생성 된 목록을 스크롤하면 버튼이 맨 위에 있습니다. – user2367219

+0

당신은 그 레이아웃을 listview에서 팽창시킬 필요가 있습니다. – KOTIOS

답변

0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#F2B1DBF3" 
    android:orientation="vertical" > 
<Button 
android:layout_alignParentTop="true" 
android:id="@+id/button" 
.. 
> 
<LinearLayout 

.. 
android:layout_below="@+id/button" 
>... 

</RelativeLayout> 

갱신

당신이 뭔가를 원했는가?

enter image description here

+0

작동하지 않습니다. 가지고있는 모든 항목에 대해 버튼이 표시됩니다. – user2367219

+0

예, 사진에있는 내용을 원했습니다. – user2367219

+0

이 링크는 전체 자습서입니다. http://www.vogella.com/articles/AndroidListView/article.html –