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

이벤트가로체기 질문입니다..

0 추천

안녕하세요 안드로이드 초보 개발자입니다..

일단소스부터 보시죠..

 

<com.newtalktalk.classes.listviewcustom  
        android:id="@+id/main_box_scrollview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#e9edee"
        android:visibility="visible" 
        android:fillViewport="true">
        
        <LinearLayout 
         android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:orientation="vertical"
         >
         
            <LinearLayout 
          android:layout_width="match_parent"
          android:layout_height="160dp"
          android:orientation="horizontal"
          >
       <RelativeLayout 
           android:layout_width="0dip"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           >
         <ImageButton 
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/common_default_profile_img"
            />
         
         <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/shadow_white_thumbnail" 
             />
         
       
       </RelativeLayout>

</LinearLayout>                 
   <ListView
       android:id="@+id/Lv_wholesale"
       android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:cacheColorHint="#00000000"
                android:choiceMode="none"
                android:clickable="false"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:longClickable="false"
                android:scrollbars="none"
       />
     </LinearLayout>
   </com.newtalktalk.classes.listviewcustom>

액티비티

private ListView Lv_wholesale;
 private View header;
 private ScrollView sc;
 
 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.test);
        Lv_wholesale= (ListView)findViewById(R.id.Lv_wholesale);
        sc = (listviewcustom)findViewById(R.id.main_box_scrollview);
        header = getLayoutInflater().inflate(R.layout.header, null, false);
//        Lv_wholesale.addHeaderView(header);
        String data[] ={"aaaa","Aafwfe","상푸우우우우움","상푸우우우우움","상푸우우우우움","상푸우우우우움",
          "aaaa","Aafwfe","상푸우우우우움","상푸우우우우움","상푸우우우우움","상푸우우우우움",
          "aaaa","Aafwfe","상푸우우우우움","상푸우우우우움","상푸우우우우움","상푸우우우우움",
          "aaaa","Aafwfe","상푸우우우우움","상푸우우우우움","상푸우우우우움","상푸우우우우움"};
        
        Lv_wholesale.setAdapter(new PopupListView(this, data));
        sc.setOnTouchListener(new OnTouchListener() {
   
   @Override
   public boolean onTouch(View v, MotionEvent event) {
    // TODO Auto-generated method stub
    Log.d("--", "in");
    Lv_wholesale.requestDisallowInterceptTouchEvent(true);
    return true;
   }
  });

listviewcustom

public listviewcustom(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  // TODO Auto-generated constructor stub
 }

 public listviewcustom(Context context, AttributeSet attrs) {
  super(context, attrs);
  // TODO Auto-generated constructor stub
 }

 public listviewcustom(Context context) {
  super(context);
  // TODO Auto-generated constructor stub
 }
 
 
 @Override
 public boolean onInterceptTouchEvent(MotionEvent ev) {
  // TODO Auto-generated method stub
  return super.onInterceptTouchEvent(ev);
 }

테스트를 하는거라 파일이름은 신경쓰지않았습니다.

 

현제 xml은 커스텀스크롤뷰 안에 listview가 있습니다..

제가 구현하려구 하는것은 listview header를 사용한것처럼 스크롤이 전체 화면이 되어야 하는데요..

여기저기 구글링해서 알아보고 한 결과물이 저것입니다 ㅠㅠ

아무리해도.. listview의 스크롤은 막고 scrollview의 스크롤만 사용하려구 해도 안되네요 ㅠㅠ

고수님들 도와주세요 ㅠㅠ

mamongs (4,050 포인트) 님이 2013년 7월 3일 질문

2개의 답변

0 추천
listview와 scrollview를 동시에 쓰려고 하는 이유가 무엇인가요?

결론적으로 2개는 같은 기능을 하는 view들인데요.
pulak (2,610 포인트) 님이 2013년 7월 3일 답변
이해를 돕기위해 xml을 줄엿습니다..
지금 보는 xml은 같은기능을 하고있지만..
listview상단에 컨텐츠가 원래 들어있구요..
그 컨텐츠를 listview header로 add하면 되기는 하는데
제가 원하는 모양으로 나오질않아서요 ㅠㅠ
즉 listview 상단에 컨텐츠가 있고 그것도 스크롤이 되어야 한다는 말씀이신가요?
ScrollView에 View를 추가 하는 방식으로 꾸며주시던가 아니면 arrayadapter를 이용해서 한줄 한줄 컨트롤 해주시는 방법도 해보셨나요?
네.. 둘다 스크롤이벤트가 먹지 않아서.. 고민중입니다 ㅠㅠ
구글서치 결과 intercept를 사용하면 이벤트를 부모에서 가로챌수가 있다던데 아무리해도 안되서 이렇게 질문을 올리게됫네요 ㅠㅠ
음 제가 생각했을때는 scrollView나 listView 둘중 하나만 쓰는 방법을 찾아 보시는게 더 좋을듯 합니다.
그런가요..관심감사합니다 ㅠㅠ
0 추천

간단합니다.

리스트 뷰에 setOnTouchListener 를 두고 그곳에서 scroll 바에 onTouchEvent를 호출 하세요

        list.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                scroll.onTouchEvent(event);
                return true;
            }
        });

 

aucd29 (218,390 포인트) 님이 2013년 7월 3일 답변
방금 이방법도 해봣는데 ㅠㅠ 안되는군요 흐아 ㅠㅠㅠ
테스트 하고 올린건데 말이죠, 올리신 환경 자체가  다른가봅니다만?
제가 올린 저 소스 카피 해서 실행하셧는데 됫다는 말씀이신가요?;;;;
아니면 따로 스크롤이랑 리스트뷰를 생성해서 됫다는말씀이신가요?
따로 하셧다면 제가 뭔갈 잘못햇군요;
...