터치

list = (HorizontalScrollView)findViewById(R.id.list);
list.setOnTouchListener(this);

@Override
public boolean onTouchEvent(MotionEvent ev) {
Log.v("123", "456");
   switch (ev.getAction()) {    
       case MotionEvent.ACTION_DOWN:
           // if we can scroll pass the event to the superclass
       default:
           return super.onTouchEvent(ev);
   }
}


또한
NewsObject p1 = null; 
p1 = new NewsObject(feed.getItem(i).getTitle()....
m_orders.add(p1);
추가하여 오브젝트를 이용할 경우는

gItem.imageView.setOnClickListener(clickResult);
gItem.imageView.setOnTouchListener(touchResult);


OnTouchListener touchResult = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.v("eventX:eventY", "123");
 
if(event.getAction() == MotionEvent.ACTION_DOWN) {
xAtDown = event.getX(); // 터치 시작지점 x좌표 저장
}else if(event.getAction() == MotionEvent.ACTION_UP){
xAtUp = event.getX(); // 터치 끝난지점 x좌표 저장
if( (xAtUp + 100) < xAtDown ) {
// 왼쪽 방향 에니메이션 지정
errorFlag = false;

//currentPosition++;
//nextImage();
}
else if ((xAtUp-100) > xAtDown){
// 오른쪽 방향 에니메이션 지정
errorFlag = false;
//currentPosition--;
//preImage();
}
}
 
return true;
}
};
OnClickListener clickResult = new OnClickListener() {
public void onClick(View v) {
//pb.setVisibility(View.VISIBLE);
if(slide != null){
//slide.animateClose();
// slideImage.setBackgroundResource(R.drawable.cartoon_viewpage_bot_button_wide_up);
}
final int i = v.getId();
// Toast noti = Toast.makeText(getApplicationContext(), i +" is Clicked", Toast.LENGTH_SHORT);
// noti.show();
clickPosition = i;
pb.setVisibility(View.VISIBLE);
Log.v("click", Integer.toString(i));
Log.v("maxLength", Integer.toString(maxLength));
Log.v("currentPosition", Integer.toString(currentPosition));
if(maxLength <= clickPosition+1){
//setContents(feed.getItem(i),i);
Handler handle = new Handler();
pb.setVisibility(View.VISIBLE);
handle.postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
page++;
updateNews();
}
}, 1000);
 
}else{
Handler handle = new Handler();
pb.setVisibility(View.VISIBLE);
handle.postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
setContents(feed.getItem(i),i);
}
}, 1000);
}
}
}; 
Posted by 예배하는 프로그래머

댓글을 달아 주세요