This new code isn't working for me. The first set worked.
On Mon, Aug 25, 2008 at 6:48 PM, adamrocker <[EMAIL PROTECTED]> wrote:
>
> Is this a bug?
> Android can't recognize the difference between
> the motion of long touch action and the motion of move action.
>
> It is different between the long touch action and the move action,
> isn't it?
>
> So, I modified my code without using onInterceptTouchEvent.
>
> /*------ ZoomMapView.java -------*/
> public class ZoomMapView extends MapView implements
> OnLongClickListener {
>
> private static final int FILL = ViewGroup.LayoutParams.FILL_PARENT;
> private boolean moving;
> private ZoomControls zoomControls;
>
> public ZoomMapView(Context context, String apiKey) {
> super(context, apiKey);
>
> // long click settings.
> moving = false;
> setClickable(true);
> setLongClickable(true);
> setOnLongClickListener(this);
>
> // ZoomControls settings.
> zoomControls = (ZoomControls) getZoomControls();
> zoomControls.setLayoutParams(new ViewGroup.LayoutParams(FILL,
> FILL));
> zoomControls.setGravity(Gravity.BOTTOM +
> Gravity.CENTER_HORIZONTAL);
> addView(zoomControls);
> }
>
> // OnLongClickListener interface method
> public boolean onLongClick(View arg0) {
> if (!moving) {
> displayZoomControls(true);
> }
> return true;
> }
>
> @Override
> public boolean onTouchEvent(MotionEvent me) {
> switch (me.getAction()) {
> case MotionEvent.ACTION_MOVE:
> moving = true;
> break;
> case MotionEvent.ACTION_UP:
> if (moving) {
> zoomControls.hide();
> }
> moving = false;
> break;
> }
>
> return super.onTouchEvent(me);
> }
> }
>
>
> This code doesn't trigger another behavior like onInterceptTouchEvent.
> What do you think about my code?
>
>
> On 8月26日, 午前2:32, 6real <[EMAIL PROTECTED]> wrote:
>> Thanks for your code !
>>
>> I miss setClickable and I also found setEnabled.
>> My code ran on the previous SDK ... I don't know if it is usefull to
>> indicate this on the migration tips...
>>
>> On 25 août, 19:24, marcel-182 <[EMAIL PROTECTED]> wrote:
>>
>> > Thanks for the code. I have just one remark:
>> > onInterceptTouchEvent(MotionEvent ev) has to return true in order to
>> > be able to scroll while the ZoomControls are being displayed. But I'm
>> > not sure if that triggers another bad behaviour :-).
>>
>> > On 25 Aug., 17:36, adamrocker <[EMAIL PROTECTED]> wrote:
>>
>> > > Hi.
>>
>> > > I'm so sorry for my code to confuse all of you.
>> > > This is the shortest sample.
>>
>> > > /* BEGIN ------------------------------------------*/
>>
>> > > /*------ ZoomControlMapSample.java -------*/
>> > > public class ZoomControlMapSample extends MapActivity {
>> > > private static final String API_KEY = "mapapikey";
>>
>> > > @Override
>> > > public void onCreate(Bundle savedInstanceState) {
>> > > super.onCreate(savedInstanceState);
>> > > MapView zmv = new ZoomMapView(this, API_KEY);
>> > > setContentView(zmv);
>> > > }
>>
>> > > @Override
>> > > protected boolean isRouteDisplayed() { return false; }
>>
>> > > }
>>
>> > > /*------ ZoomMapView.java -------*/
>> > > public class ZoomMapView extends MapView implements
>> > > OnLongClickListener {
>>
>> > > private static final int FILL =
>> > > ViewGroup.LayoutParams.FILL_PARENT;
>>
>> > > public ZoomMapView(Context context, String apiKey) {
>> > > super(context, apiKey);
>>
>> > > // long click settings.
>> > > setClickable(true);
>> > > setLongClickable(true);
>> > > setOnLongClickListener(this);
>>
>> > > // ZoomControls settings.
>> > > ZoomControls zoomControls = (ZoomControls)
>> > > getZoomControls();
>> > > zoomControls.setLayoutParams(new
>> > > ViewGroup.LayoutParams(FILL,
>> > > FILL));
>> > > zoomControls.setGravity(Gravity.BOTTOM +
>> > > Gravity.CENTER_HORIZONTAL);
>> > > addView(zoomControls);
>> > > }
>>
>> > > // OnLongClickListener interface method
>> > > public boolean onLongClick(View arg0) {
>> > > displayZoomControls(true);
>> > > return false;
>> > > }
>>
>> > > @Override
>> > > public boolean onInterceptTouchEvent(MotionEvent ev) {
>> > > onTouchEvent(ev);
>> > > return false;
>> > > }
>>
>> > > }
>>
>> > > /*------ AndroidManifest.java -------*/
>> > > <?xml version="1.0" encoding="utf-8"?>
>> > > <manifest xmlns:android="http://schemas.android.com/apk/res/android"
>> > > package="com.adamrocker.android.sample.map.zoom">
>> > > <application android:icon="@drawable/icon" android:label="@string/
>> > > app_name">
>> > > <activity android:name=".ZoomControlMapSample"
>> > > android:label="@string/app_name">
>> > > <intent-filter>
>> > > <action android:name="android.intent.action.MAIN" />
>> > > <category
>> > > android:name="android.intent.category.LAUNCHER" />
>> > > </intent-filter>
>> > > </activity>
>> > > <uses-library android:name="com.google.android.maps" />
>> > > </application>
>> > > <uses-permission android:name="android.permission.INTERNET" />
>> > > </manifest>
>>
>> > > /*------------------------------------------ END */
>>
>> > > These are the all files except the R.java.
>> > > Thank you, jokochi. Your advice is useful.
> >
>
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---