开发者

Android 2.1 fling gesture captured on textview but still a contextmenu opens

The following problem seems unique to 2.1, happens both on an emulator and on a nexus. The same example works fine on other platforms I've tested (1.5, 1.6 and 2.0 emulators).

I've added created gestureListener as described in this post. The difference is that I've added the listener on a TextView which also has a contextMenu registered, i.e. sth like the following:

 onCreate(...) {
     ...
     // Layout contains a large TextView on which I want to add a context menu
     tv = findViewById(R.id.text_view);
     tv.registerForContextMenu(this);

     // create the gestureListener according above mentioned post.
     gestureListener = ...
     // set the listener on the text-view
     tv.setOnTouchListener(gestureListener);
     ...
}

When testing it, the correct gesture is recognized alright, but every other time it also causes the context menu to be opened. As the same example is working on non 2.1 platforms, I've got a feeling it is not my code that is the problem...

Thankful for any suggestions.

Upda开发者_开发问答te: Seems that the return value is flipped somewhere. If I let onFling() return the "wrong" value, i.e. true when the event is skipped and false when it was consumed, it works correctly in 2.1. But of course, that doesn't work on the other platforms. Seems like its time for an ugly workaround...


Thanks for the link steelbytes. I implemented the cancel-and-return-false solution in the last comment (Dec 27, 2010) but just for my onFling event and it appears to work on 1.6 as well as 2.x devices.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜