마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

리스트뷰 자동스크롤이 안생깁니다!

0 추천

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:stretchColumns="*" >

                <TableRow>

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="2.2"
                        android:background="#BDBDBD"
                        android:gravity="center"
                        android:text="test1"
                        android:textColor="#000000" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.5"
                        android:background="#BDBDBD"
                        android:gravity="center"
                        android:text="test2"
                        android:textColor="#000000" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1.5"
                        android:background="#BDBDBD"
                        android:gravity="center"
                        android:text="test3"
                        android:textColor="#000000" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="5"
                        android:background="#BDBDBD"
                        android:gravity="center"
                        android:text="test4"
                        android:textColor="#000000" />
                </TableRow>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="0.8dp"
                    android:background="#000000" >
                </View>
            </TableLayout>

            <ListView
                android:id="@+id/cash_point_list"
                android:layout_width="match_parent"
                android:layout_height="100dp" >
            </ListView>
        </LinearLayout>

제가 알기로 리스트뷰에 일정이상 데이터가 잡히면 스크롤로 표시되면서 볼수있다고 알고있습니다만..

저렇게 일정한 크기를 주고 데이터를 집어넣으니 스크롤은 안보이고 데이터가 짤려서 표시가 되네요

혹시 다른방법이 있나요?

초보개발자 님이 2015년 7월 21일 질문
2015년 7월 21일 reopened

1개의 답변

0 추천
 
채택된 답변
ListView lv = (ListView)findViewById(R.id.myListView);  // your listview inside scrollview
lv.setOnTouchListener(new ListView.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            int action = event.getAction();
            switch (action) {
            case MotionEvent.ACTION_DOWN:
                // Disallow ScrollView to intercept touch events.
                v.getParent().requestDisallowInterceptTouchEvent(true);
                break;

            case MotionEvent.ACTION_UP:
                // Allow ScrollView to intercept touch events.
                v.getParent().requestDisallowInterceptTouchEvent(false);
                break;
            }

            // Handle ListView touch events.
            v.onTouchEvent(event);
            return true;
        }
    });

자체 답변!

이렇게 스크롤을 해결햇습니다.

 

익명 님이 2015년 7월 21일 답변
...