Проблема с Android: невозможно добавить более 11 представлений в ScrollView

Это мой первый вопрос о stackOverflow, так что давайте:

У меня есть этот макет:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<LinearLayout
android:id="@+id/widget31"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/set_reader_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Reader Settings:"
android:typeface="serif"
android:textStyle="bold"
android:textSize="20sp"
android:gravity="left"
>
</TextView>
<LinearLayout
android:id="@+id/widget42"
android:layout_width="fill_parent"
android:layout_height="2px"
android:orientation="vertical"
android:background="#88ffffff"
android:layout_marginBottom="10px"
/>
<CheckBox
android:id="@+id/set_auto_mark_cb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Auto mark as read"
>
</CheckBox>
<CheckBox
android:id="@+id/set_auto_mark_cb12"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Auto mark as read"
>
</CheckBox>
<CheckBox
android:id="@+id/set_unread_cb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Show unread only"
>
</CheckBox>
<CheckBox
android:id="@+id/set_skip_cb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Mark as read on skip"
>
</CheckBox>
<TextView
android:id="@+id/set_click_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="On feed content click, do:"
android:typeface="serif"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginTop="10px"
>
</TextView>
<LinearLayout
android:id="@+id/widget41"
android:layout_width="fill_parent"
android:layout_height="2px"
android:orientation="vertical"
android:background="#88ffffff"
android:layout_marginBottom="10px"
/>
<Spinner
android:id="@+id/set_action_spin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:layout_marginBottom="5px"
android:layout_marginLeft="5px"
android:layout_marginRight="5px"
android:drawSelectorOnTop="true"
android:layout_gravity="center_horizontal"
>
</Spinner>
<TextView
android:id="@+id/set_account_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Change reader account:"
android:typeface="serif"
android:textStyle="bold"
android:textSize="20sp"
android:gravity="left"
android:layout_marginTop="10px"
>
</TextView>
<LinearLayout
android:id="@+id/widget42"
android:layout_width="fill_parent"
android:layout_height="2px"
android:orientation="vertical"
android:background="#88ffffff"
android:layout_marginBottom="10px"
/>
<Button
android:id="@+id/set_account_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change">
</Button>
</LinearLayout>
</ScrollView>

Но если я добавлю еще одно представление (CheckBox, TextView, LinearLayout) в этот макет (не в RunTime, в CodeTime, я не пытался сделать это в RunTime), когда я открываю это (setContentView (sv)), он говорит:

Окно уже сфокусировано, игнорируя усиление фокуса: com.android.internal.view.IInputMethodClient$Stub$Proxy@462fa1b0

Я могу изменить любой вид, но я не могу добавить новый.

Это мой код надувания:

LayoutInflater inf = getLayoutInflater();
ScrollView sv = (ScrollView)inf.inflate(R.layout.layout_settings, null);
//More code here

Итак, есть ли максимальное количество просмотров, которые может разместить ScrollView?

Спасибо В любом случае.


person Afonso Lage    schedule 02.03.2011    source источник


Ответы (1)


Я не вижу проблем в том, чтобы иметь больше виджетов/компонентов внутри вашего LinearLayout. Насколько я знаю, единственным ограничением ScrollView является то, что у него должен быть только один потомок. Зачем вы раздуваете макет? Вы можете просто использовать setContentView(R.layout.layout_settings). Я попробовал ваш XML-файл и могу без проблем добавить больше представлений.

person Zarah    schedule 02.03.2011
comment
Я не знаю, почему так... Я раздуваю, чтобы добавить несколько слушателей... но в любом случае спасибо, я сделаю весь свой макет с кодированием... - person Afonso Lage; 06.03.2011
comment
Слушатель чего? Я думаю, вы можете добавить слушателей без надувания. - person Zarah; 06.03.2011