Days pass but I still can't find an answer.
I try to trace stack, but I can't understand how the system get
"position" parameter since the source code of SDK is not available:
ListView.performItemClick(View, int, long) line: 2968
AbsListView$PerformClick.run() line: 1406
When I call View.PerformClick, SDK says "You shouldn't call this."
I have a way to call performItemClick directly, but I don't know how
to get position on a ListView using MotionEvent information.
After all, why if I override ListActivity.dispatchTouchEvent,
ListActivity.onListItemClick will become disable? Is this a bug?
Should I report it to google?
On 9月22日, 下午5時45分, Urakagi <[EMAIL PROTECTED]> wrote:
> Oops, I'm wrong, I can't get position.
> Is there other ways to get position in a ListView using X and Y
> message in MotionEvent?
>
> On 9月22日, 上午9時24分, Urakagi <[EMAIL PROTECTED]> wrote:
>
> > That sounds good, but I also have a problem for it.
>
> > protected void onListItemClick(ListView l, View v, int position, long
> > id)
>
> > I know ListView, View, and position, but how can I get id?
>
> > On 9月20日, 上午5時37分, Teo Hong Siang <[EMAIL PROTECTED]> wrote:
>
> > > Here's my suggestion:
> > > If your code indispatchTouchEventcan determine that the gesture is
> > > empty, then you can call onListItemClick() withindispatchTouchEvent.
> > > If the gesture is not empty, then do whatever you want to do.
>
> > > On Sep 19, 2:45 am, Urakagi <[EMAIL PROTECTED]> wrote:
>
> > > > Um, I want to usedispatchTouchEvent() to implement a gesture system,
> > > > so I have code like this:
>
> > > > public booleandispatchTouchEvent(MotionEvent ev) {
> > > > boolean rtn = mGesture.onTouchEvent(ev);
>
> > > > if (ev.getAction() == MotionEvent.ACTION_UP) {
> > > > Log.v("dispatch", "Gesture=" +
> > > > mGesture.getGestureString());
> > > > if(mGesture.getGestureString().equals("")) {
> > > > return super.dispatchTouchEvent(ev);
> > > > }
> > > > }
>
> > > > return rtn;
> > > > }
>
> > > > which means, if the gesture is empty (indicates a click), I want to do
> > > > original things like onListItemClick().
> > > > But calling super.dispatchTouchEvent(ev); will not trigger
> > > > onListItemClick(). So what I want to do is:
>
> > > > If it's a simple click, call onListItemClick().
> > > > Otherwise, calldispatchTouchEvent().
>
> > > > Thanks for replying. (Sorry for my poor English since I'm not a native
> > > > English speaker)
>
> > > > On 9 $B7n (B19 $BF| (B, $B2<8a (B4 $B;~ (B02 $BJ, (B, hackbod <[EMAIL
> > > > PROTECTED]> wrote:
>
> > > > > Well yes,dispatchTouchEvent() dispatching touch events through the
> > > > > view. If you do this:
>
> > > > > @Override public booleandispatchTouchEvent(MotionEvent ev) {
> > > > > return super.dispatchTouchEvent(ev);
>
> > > > > }
>
> > > > > it will behave exactly the same as if you didn't override the method,
> > > > > so I'm not sure what you mean by it not working.
>
> > > > > What are you trying to accomplish?
>
> > > > > On Sep 19, 12:12 am, Urakagi <[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi, I have a class extending ListActivity, and I want to catch
> > > > > > touchevent on it so I overridedispatchTouchEvent.
>
> > > > > > @Override
> > > > > > public booleandispatchTouchEvent(MotionEvent ev) {
> > > > > > ...
>
> > > > > > }
>
> > > > > > And since it's a ListActivity, of cource I want to override the
> > > > > > onListItemClick(), too:
> > > > > > @Override
> > > > > > protected void onListItemClick(ListView l, View v, int position,
> > > > > > long
> > > > > > id) {
> > > > > > ...
>
> > > > > > }
>
> > > > > > But now I find that thedispatchTouchEvent() will intercept ALL touch
> > > > > > event on the activity, so onListItemClick() will never be called.
> > > > > > I tried
> > > > > > super.dispatchTouchEvent(ev);
> > > > > > but it does not work.
>
> > > > > > Anyone has any idea for this? Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---