onclicklistener works in 2.1 but not 2.2?

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

onclicklistener works in 2.1 but not 2.2?

Postby richardjohn » Fri Sep 10, 2010 8:06 pm

I have been coding with android 2.1 for a couple months now. :o I have an app with on view.onClickListener that triggers when I run an adroid 2.1 emulator, but not on a 2.2 emulator or actual droid phone running 2.2

Simple onClickListener to change activities:
Code: Select all
    public View.OnClickListener caseClickListener = new View.OnClickListener() {
        public void onClick(View v) {
            Intent myIntent = new Intent(v.getContext(), Attempts.class);
            startActivityForResult(myIntent,0);
        }
    };


This is hanging out in my main activity class. Upon loading, a class is created (called aCase) that extends a LinearLayout. I say:
Code: Select all
  aCase.setOnClickListener(caseClickListener);

And I see that this is called, but when I click the LinearLayout that is aCase, the caseClickListener does not trigger or fire in 2.2, like it did in 2.1! :cry:

Any ideas? :idea:

I have tried setting all sorts of things to focusable and focusableInTouchMode, like someone mentioned on the internets, but it has no effect. What changed from 2.1 to 2.2? My project still only needs 2.1 to run so I would hope the code would be backwards compatible for a 2.2 device, but no go!! :x
richardjohn
Freshman
Freshman
 
Posts: 3
Joined: Fri Sep 10, 2010 7:56 pm

Top

Re: onclicklistener works in 2.1 but not 2.2?

Postby richardjohn » Mon Sep 13, 2010 2:43 pm

Can anyone point me to areas of the SDK or API that changed between 2.1 and 2.2??

I still don't see how 2.2 would not be backwards compatible with stuff that works in 2.1 though.
richardjohn
Freshman
Freshman
 
Posts: 3
Joined: Fri Sep 10, 2010 7:56 pm

Re: onclicklistener works in 2.1 but not 2.2?

Postby richardjohn » Mon Sep 13, 2010 4:16 pm

Code: Select all
    public boolean onInterceptTouchEvent(MotionEvent ev){
        return true;
    }


I put that in the (aCase) class. Now it works. I have no idea.
richardjohn
Freshman
Freshman
 
Posts: 3
Joined: Fri Sep 10, 2010 7:56 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 4 guests