See http://www.passsy.de/multitouch-for-all-views/#comment-47486 of which the most relevant code appears below.
If one "TestButton" which extends button is pressed, that view is passed to my "TestButton" code and I can animate that button/view. But I want to animate another view as well. How can I animate a different view from with the view I am creating here or how can I notify my activity to DO ACTION? This works on button touched:
startAnimation(animationstd);
but on another button:
useiv.startAnimation(animationstd);
causes a null pointer exception.
CODE:
package de.passsy.multitouch;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.Button;
public class TestButton extends Button {
public TestButton(final Context context, final AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(final MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
final Animation animationstd = AnimationUtils.loadAnimation(getContext(),
R.anim.fromleft);
useiv = (TestButton) findViewById(R.id.imageButton1);
useiv.startAnimation(animationstd); //this line = null pointer exception
}
return super.onTouchEvent(event);
}
}