0

Imagine you have a big linearlayout, let's call it originalLayout that has a gestureDetector set to it. Then you also inflate a ReLayNewsItem layout and put it into the originalLayout.

LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout ReLayNewsItem = (RelativeLayout) inflater.inflate(R.layout.newsitem, null); 
...
originalLayout.addView(ReLayNewsItem);

Now gestureDetector works only on the empty space of the originalLayout and does not work where I have the ReLayNewsItem.

What's the best way to make ReLayNewsItem not obscure gesture?

P.S. I can not set the same gestureDetector onto ReLayNewsItem.

ReLayNewsItem.setClickable(false); - doesn't work.

Roger Travis
  • 8,402
  • 18
  • 67
  • 94

1 Answers1

1

Whenever there is touch/gesture/motion event on the ReLayNewsItem, let your layout consume it like returning mGesture.onTouchEvent(ReLayNewsItem_event) in your touch event method of ReLayNewsItem or layout.dispatchTouchEvent(ReLayNewsItem_event).

Read Event Handler point here: http://developer.android.com/guide/topics/ui/ui-events.html

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
  • hmm, didn't really get it, how do I pass it then to originalLayout? – Roger Travis Jul 14 '12 at 17:42
  • I guess you have gesture listener for your original layout. When you have touch events on the ReLayNewsItem you just use your gesture listener instance to consume the event. See here how they are passing events to the gesture listener http://stackoverflow.com/questions/4804798/doubletap-in-android – Nikola Despotoski Jul 14 '12 at 17:46
  • tried, but it gives me this error :) http://stackoverflow.com/questions/11486178/anroid-dispatchtouchevent-gives-me-a-stackoverflowerror – Roger Travis Jul 14 '12 at 18:13