2015-04-23 4 views
-3

У меня есть макет с несколькими текстовыми полями и флажками. Между ними есть listview. Когда я добавляю три или несколько элементов, я не вижу их в списке, в списке нет полосы прокрутки.Невозможно прокрутить список элементов списка

Это мой макет:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" > 

     <TextView 
      android:id="@+id/textView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Text" /> 

     <EditText 
      android:id="@+id/editText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Text" /> 

     <EditText 
      android:id="@+id/editText2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Text" /> 

     <EditText 
      android:id="@+id/editText3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <TextView 
      android:id="@+id/textView4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Text" /> 

     <EditText 
      android:id="@+id/editText4" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <Button 
      android:id="@+id/button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Button" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="163dp" 
      android:orientation="horizontal" > 

      <!-- -------------HERE IS MY LISTVIEW--------------- -->     

      <ListView 
       android:id="@+id/listView" 
       android:layout_width="wrap_content" 
       android:layout_height="fill_parent" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/linearLayoutCheckBox" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignRight="@+id/linearLayoutGlavni" 
      android:layout_below="@+id/linearLayoutGlavni" 
      android:layout_weight="1" 
      android:orientation="vertical" > 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="horizontal" > 

       <CheckBox 
        android:id="@+id/checkBox" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Reklamacija dobavljaču" /> 

       <CheckBox 
        android:id="@+id/checkBox2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_marginLeft="14dp" 
        android:layout_toRightOf="@+id/checkBox" 
        android:text="Prenamjena robe" /> 
      </RelativeLayout> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="horizontal" > 

       <CheckBox 
        android:id="@+id/checkBox3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Otpis robe" /> 

       <CheckBox 
        android:id="@+id/checkBox4" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_marginLeft="111dp" 
        android:layout_toRightOf="@+id/checkBox3" 
        android:text="Upozorenje djelatniku" /> 
      </RelativeLayout> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="horizontal" > 

       <CheckBox 
        android:id="@+id/checkBox5" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Obuka djelatnika" /> 

       <CheckBox 
        android:id="@+id/checkBox6" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_marginLeft="64dp" 
        android:layout_toRightOf="@+id/checkBox5" 
        android:text="Održavanje" /> 
      </RelativeLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="horizontal" 
       android:weightSum="1" > 

       <TextView 
        android:id="@+id/textView5" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="New Text" /> 

       <EditText 
        android:id="@+id/editText5" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="0.68" /> 
      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 

</ScrollView> 

Есть ли что-то отсутствует в коде макета или это должно быть решено с помощью кода?

+0

Компоновка вы вывесили не содержит 'ListView', но что более важно, это даже не действует ... –

+0

Он содержит, Я проверил. – Josef

+1

Я вижу, как должен выглядеть этот макет? Честно говоря, весь этот xml выглядит сумасшедшим с множеством ненужных представлений. Это может быть значительно упрощено. Но, как я уже сказал. Это недопустимо xml. Пожалуйста, исправьте это. И ваш 'ListView' помещен в' ScrollView', который не будет работать. Вложенные прокручиваемые элементы невозможно в Android. –

ответ

0

Вы никогда не должны ставить ListView в Scrollview, потому что ListView является autoScrollable, когда ее размер увеличивается, чем экран.

Пожалуйста, обратитесь к этой ссылке. Компоненты компонента Listview. Здесь вы можете найти лучшие подходы Как использовать ListView правильно

https://www.youtube.com/watch?v=wDBM6wVEO70

+0

Добро пожаловать в переполнение стека! Просьба указать наиболее релевантную часть ссылки, если целевой сайт недоступен или постоянно находится в автономном режиме. См. [Как написать хороший ответ] (http://stackoverflow.com/help/how-to-answer). – Gattsu

+0

Я удалил ScrollView, и он работает нормально. Благодаря! – Josef

+0

все же говорят, что вы не можете использовать два вида прокрутки друг в друге –

-1

Я мог бы предложить вам разместить только ListView в ScrollView. Я думаю, что это сработает, потому что я уже пробовал. Поэтому, пожалуйста, попробуйте что-то вроде этого

<ScrollView 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="163dp" 

    <ListView 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:id="@+id/listView" /> 
</ScrollView> 
+0

Вложения в прокручиваемые элементы в андроиде невозможны. Каждый раз, когда что-то подобное работает, это просто случайно. –

+0

Я уверен, что это не сработает – Gattsu

+0

Я не знаю, t сказать, чтобы поместить ScrollView int oanother ScrollView, но поместить ListView в ScrollView. Когда вы не согласны, что вы можете предложить? –

Смежные вопросы