0

嗨,我有一个布局,它有 3 列,每列有 4 个 ListViews(第一个用作 TextView 并且工作正常)。我从 ArrayList 将信息传递给这个 ListViews,如果 ArrayLists 是 1 或 2 行,这很好。但是,如果在显示列表视图时这些数组列表有很多数据,则第一个列表视图会很好地显示此信息,并且用户可以在滚动时显示所有项目,但不会显示此列表视图下的其他 2 个列表视图。这是填充这些列表视图的布局和 java 代码。布局:

<?xml version="1.0" encoding="utf-8"?>

    <LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/green"
    android:orientation="horizontal">

        <RelativeLayout android:layout_weight="1" 
                    android:layout_height="fill_parent" 
                    android:layout_width="fill_parent">
                   <ListView   android:id="@+id/titulo1" 
                            android:layout_height="40dp" 
                            android:layout_gravity="center"
                            android:gravity="center"
                           android:textSize="40sp"
                                                       android:background="@drawable/celdaazul"
                            android:layout_width="fill_parent">

                </ListView>

                <ListView   android:id="@+id/list1" 
                    android:scrollbarThumbVertical="@drawable/scrollbar" 
                    android:fadeScrollbars="false"
                            android:layout_height="wrap_content" 
                            android:layout_below="@id/titulo1"
                            android:background="@drawable/celdanegra"

                            android:layout_width="fill_parent">

                </ListView>

                   <ListView   android:id="@+id/list1b" 
                    android:scrollbarThumbVertical="@drawable/scrollbar" 
                    android:fadeScrollbars="false"
                            android:layout_height="wrap_content" 
                            android:layout_below="@id/list1"
                            android:background="@drawable/celdaroja"
                            android:layout_width="fill_parent">


                </ListView>
                 <ListView   android:id="@+id/list1c" 
                    android:scrollbarThumbVertical="@drawable/scrollbar" 
                    android:fadeScrollbars="false"
                            android:layout_height="wrap_content" 
                            android:layout_below="@id/list1b"

                            android:layout_width="fill_parent">
                            </ListView>
    </RelativeLayout>

  <RelativeLayout android:layout_weight="1" 
                    android:layout_height="fill_parent" 
                    android:layout_width="fill_parent">
                   <ListView   android:id="@+id/titulo2" 
                            android:layout_height="40dp" 
                            android:textSize="40sp"
                                                       android:background="@drawable/celdaazul"
                             android:layout_gravity="center"
                            android:gravity="center"
                            android:layout_width="fill_parent">

                </ListView>

                <ListView   android:id="@+id/list2" 
                    android:scrollbarThumbVertical="@drawable/scrollbar" 
                    android:fadeScrollbars="false"
                            android:layout_height="wrap_content" 
                            android:layout_below="@id/titulo2"
                                                    android:background="@drawable/celdanegra"

                            android:textStyle="bold"
                            android:layout_width="fill_parent">


                </ListView>
                   <ListView   android:id="@+id/list2b" 
                    android:scrollbarThumbVertical="@drawable/scrollbar" 
                    android:fadeScrollbars="false"
                            android:layout_height="wrap_content" 
                            android:layout_below="@id/list2"
                            android:background="@drawable/celdaroja"
                            android:layout_width="fill_parent">


                </ListView>
                 <ListView   android:id="@+id/list2c" 
                    android:scrollbarThumbVertical="@drawable/scrollbar" 
                    android:fadeScrollbars="false"
                            android:layout_height="wrap_content" 
                            android:layout_below="@id/list2b"

                            android:layout_width="fill_parent">
                            </ListView>
    </RelativeLayout>
  <RelativeLayout android:layout_weight="1" 
                    android:layout_height="fill_parent" 
                    android:layout_width="fill_parent">


                   <ListView   android:id="@+id/titulo3" 
                            android:layout_height="40dp" 
                             android:textSize="40sp"
                              android:layout_gravity="center"
                            android:gravity="center"
                                                       android:background="@drawable/celdaazul"

                            android:layout_width="fill_parent">

                </ListView>

                <ListView   android:id="@+id/list3" 
                            android:layout_height="wrap_content" 
                            android:scrollbarThumbVertical="@drawable/scrollbar" 
                    android:fadeScrollbars="false"
                        android:background="@drawable/celdanegra"
                            android:layout_below="@id/titulo3"
                            android:layout_width="fill_parent">

                </ListView>
                   <ListView   android:id="@+id/list3b" 
                    android:scrollbarThumbVertical="@drawable/scrollbar" 
                    android:fadeScrollbars="false"
                            android:layout_height="wrap_content" 
                            android:layout_below="@id/list3"
                            android:background="@drawable/celdaroja"
                            android:layout_width="fill_parent">


                </ListView>
                 <ListView   android:id="@+id/list3c" 
                    android:scrollbarThumbVertical="@drawable/scrollbar" 
                    android:fadeScrollbars="false"
                            android:layout_height="wrap_content" 
                            android:layout_below="@id/list3b"

                            android:layout_width="fill_parent">
                            </ListView>
    </RelativeLayout>
     </LinearLayout>

代码:

public class LayoutThree extends Fragment {
     private ListView lv1 = null;
     private ListView lv2 = null;
     private ListView lv3 = null;
     private ListView lv4 = null;
     private ListView lv5 = null;
     private ListView lv6 = null;
     private ListView lv1b = null;
     private ListView lv1c = null;
     private ListView lv2b = null;
     private ListView lv2c = null;
     private ListView lv3b = null;
     private ListView lv3c = null;

        static List<String> list1 = new ArrayList<String>();
        static List<String> list2 = new ArrayList<String>();
        static List<String> list3 = new ArrayList<String>();

     private String s1[] = {"Tras realizar la prueba se encuentra bien y está satisfecho con su rendimiento", "Cree que lo ha hecho fatal y por ese motivo se encuentra  disgustado", "c", "d", "e", "f","r", "s", "t", "u", "v", "w", "x","r", "s", "t", "u"};
     private String s2[] = {"r", "s", "t", "u", "v", "w", "x","r", "s", "t", "u", "v", "w", "x","r", "s", "t", "u", "v", "w", "x"};
     private String s4[] = {"Sobre Rendimiento"};
     private String s5[] = {"Sobre Resel"};
     private String s6[] = {"Sobre Convocatoria"};


    public static Fragment newInstance(Context context) {
        LayoutThree f = new LayoutThree();  

        return f;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        for(int i = 0; i < XMLPullParserHandler.A1Size(); i++){
        list1.add(XMLPullParserHandler.getAutoeval1(i));}
        for(int i = 0; i < XMLPullParserHandler.A2Size(); i++){
            list2.add(XMLPullParserHandler.getAutoeval2(i));}
        for(int i = 0; i < XMLPullParserHandler.A3Size(); i++){
            list3.add(XMLPullParserHandler.getAutoeval3(i));}
        ViewGroup vista = (ViewGroup) inflater.inflate(R.layout.autoeval, null);    

       lv4 = (ListView) vista.findViewById (R.id.titulo1);
       lv5 = (ListView) vista.findViewById (R.id.titulo2);
       lv6 = (ListView) vista.findViewById (R.id.titulo3);
       lv1b = (ListView) vista.findViewById (R.id.list1b);
       lv1c  = (ListView) vista.findViewById (R.id.list1c);
       lv2b = (ListView) vista.findViewById (R.id.list2b);
       lv2c  = (ListView) vista.findViewById (R.id.list2c);
       lv3b = (ListView) vista.findViewById (R.id.list3b);
       lv3c  = (ListView) vista.findViewById (R.id.list3c);
         lv1 = (ListView) vista.findViewById (R.id.list1);
            lv2 = (ListView) vista.findViewById (R.id.list2);
            lv3 = (ListView) vista.findViewById (R.id.list3);

            lv4.setAdapter(new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, s4));
            lv5.setAdapter(new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, s5));
            lv6.setAdapter(new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, s6));
            lv1b.setAdapter(new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, s5));
            lv1c.setAdapter(new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, s5));

            lv2b.setAdapter(new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, s1));
            lv2c.setAdapter(new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, s1));
            lv1.setAdapter(new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, s5));
            lv2.setAdapter(new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, s1));
            lv3.setAdapter(new ArrayAdapter<String> (getActivity(), android.R.layout.simple_list_item_1, list3));


        return vista;
    }

}
4

0 回答 0