я полностью застрял ... моя цель - реализовать .. простое действие типа "слушателя", но я не знаю как ... вот мой код
// normaly i create an action like this
// this is JUST an example how i do this in swing
//
class la extends JFrame implements ..<someAciton>..{
JButton b = new JButton("");
add(b);
b.setAction( new Action(){
void click(){
// bla
}
});
}
моя проблема в том, что я хочусоздать эту функциональность в Android в целом в Java в настоящее время у меня есть 3 класса и 1 интерфейс
// the interface, it holds my action, wich should be performed
//
//
public interface GameActionInterface extends EventListener {
public void onTouched( MotionEvent event );
}
// this is the class whichs runs the action
//
//
public class GameActionListener {
ArrayList<GameLayoutBase>touchedListener = new ArrayList();
public void addTouchListener(GameLayoutBase obj){
touchedListener.add(obj);
}
public void onTouched( MotionEvent event){
for( GameLayoutBase elem : touchedListener ){
elem.onTouched(event);
}
}
}
// this class should to the action later
//
//
public class GameLayoutElement extends GameLayoutBase {
public GameLayoutElement(String ID) {
super(ID);
}
}
// my main class
//
//
gameEventListener = new GameActionListener();
// creating the obj
layout_Element_Player[0] = new GameLayoutElement("Builder_countA");
//
// and here is the PROBLEM - i want to overwrite the current function with my "own" code
gameEventListener.addTouchListener(layout_Element_Player[0]);
// adding the element to the listener
//
//
layout_Element_Player[0].onTouched( new GameActionInterface(){
});
Я не знаю, как решить проблему: (