2012-03-19 7 views
3

제가 주 목록에 있지만 문제는 15 개 이상의 바코드가있는 바코드를 스캔 할 때 이미 "스캔"버튼이 표시되지 않았고 스크롤보기를 사용하려고했습니다. 그게 작동하지 않습니다 : 어떤 도움이됩니까?scrollview가 작동하지 않습니다

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:fillViewport="true"> 
<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 


    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello" /> 
      <ListView 
    android:id="@android:id/list" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 


/> 
<TextView 
    android:id="@android:id/empty" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="no notes" 
    /> 
<Button 
     android:id="@+id/button" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="20dp" 
     android:text="scan"/> 




</LinearLayout> 
</ScrollView> 

의견이 있으십니까?

답변

1

Android에서는 ScrollView에서 ListView를 사용할 수 없습니다. 동일한 결과를 얻으려면 ListView를 사용하고 머리글과 바닥 글을 추가 할 수 있습니다.

addHeaderView()

당신은 ListActivity를 사용할 수 있습니다.

LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
getListView().addHeaderView(inflater.inflate(R.layout.header, null)); 
getListView().addFooterView(inflater.inflate(R.layout.footer, null)); 

바닥 글은 정확히 같은 방식으로 작동합니다 (setAdapter()를 호출하기 전에 onCreate() 함수에서 코드를 넣어) : 헤더에 대해 하나의 XML 레이아웃 파일을 생성하고있는 ListView에 추가합니다.

+0

안녕하세요, 세부 사항에서 수행하는 방법을 알 수 있습니까? 감사합니다 :) –

+0

안녕하세요, 귀하의 코드에 감사하지만, ListAdapter를 사용하지 않았지만 listView 만 사용하면 ListAdapteR을 사용할 수 밖에없는 것 같습니다. –

+0

항목을 추가하는 방법과 상관없이 머리글과 바닥 글이있는 부분이 중요합니다. – flo

0

안녕하세요. RelativeLayout 대신 LinearLayout을 사용할 수 있습니다.

그런 경우 레이아웃 하단에 버튼을 배치해야합니다. 그런 다음 다른 컨트롤을 버튼 위에 배치해야합니다. RelativeLayout에는이를 수행하는 데 도움이되는 특수 xml 속성이 있습니다. 그 후에는 ScrollView가 필요하지 않습니다.

+0

안녕하세요, LinearLayout없이 RelativeLayout 만 사용한다는 의미입니까? –

+0

나는 그저 하나 피곤했다고 생각하지만 오류 메시지와 앱이 깔끔하게 보이지만 다시 시도 할 것입니다. –

+0

제 말은'ScrollView'를 삭제하고'LinearLayout'을'RelativeLayout'으로 대체해야한다는 것입니다. –

관련 문제