2012-06-08 9 views
0

이 앱을 실행하면 충돌이 발생합니다. LinearLayout을 사용하려고 시도했지만 그다지 작동하지 않습니다. 내가 뭘 잘못 했니?이 코드가 작동하지 않는 이유 (Android - Scrollview)

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/scrollView1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<CheckBox 
    android:id="@+id/CheckBox13" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="CheckBox" /> 

<CheckBox 
    android:id="@+id/CheckBox12" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="CheckBox" /> 

<CheckBox 
    android:id="@+id/CheckBox11" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="CheckBox" /> 

<CheckBox 
    android:id="@+id/CheckBox10" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="CheckBox" /> 


</ScrollView> 
+1

우선,있는 ScrollView는 하나의 아이를 받아 들일 수 있습니다. – DeeV

+0

코드는 어디에 있습니까? 오류가 무엇입니까? LogCat 및 코드 게시. – Barak

+0

가능한 복제본 [이 체크 박스에서 스크롤보기를 사용하려면 어떻게합니까?] (http://stackoverflow.com/questions/10938419/how-can-i-use-scroll-view-on-these-checkboxes) –

답변

0

당신 만있는 ScrollView는 하나의 직접 아이를 호스팅 할 수있는 ScrollView보기

에서 단일 직접 아이를 가질 수있다.

http://developer.android.com/reference/android/widget/ScrollView.html

A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through :에서

. 이

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/scrollView1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<LinerLayout 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<CheckBox 
    android:id="@+id/CheckBox13" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="CheckBox" /> 

<CheckBox 
    android:id="@+id/CheckBox12" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="CheckBox" /> 

<CheckBox 
    android:id="@+id/CheckBox11" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="CheckBox" /> 

<CheckBox 
    android:id="@+id/CheckBox10" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="CheckBox" /> 

</LinerLayout> 

</ScrollView> 

이 로그 고양이처럼

그래서 당신의 코드는

enter image description here

+0

그건 전혀 작동하지 않았다 –

+0

어떤 오류? 무슨 실수 야? XML 또는 컴파일 시간 또는 실행 시간? –

+0

"Xml 구문 분석 오류 : 언 바운드 접두어 _ 오류" –

0

있는 ScrollView는 아이로 하나 개의보기를합니다 ..........해야합니다. 3 개의 체크 박스를 직접 입력 할 수는 없습니다. 대신

:

<ScrollView ... > 
    <LinearLayout ...> 
      <CheckBox 
       android:id="@+id/CheckBox13" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="CheckBox" /> 

      <CheckBox 
       android:id="@+id/CheckBox12" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="CheckBox" /> 

      <CheckBox 
       android:id="@+id/CheckBox11" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="CheckBox" /> 

      <CheckBox 
       android:id="@+id/CheckBox10" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="CheckBox" /> 
    </LinearLayout> 
</ScrollView> 
+0

도 있습니다. –

관련 문제