Jump to content

pattern-observer


Recommended Posts

Bonjour,
Je veux déclenché une méthode d'une classe A à partir d'un bouton d'une boite de dialogue, j'ai utilisé un pattern-observer mais je n'arrive pas à entrer dans la méthode update().
Puisqu'une boite de dialogue ne peut pas hériter de deux classes, j'ai crée une classe observe héritant de Observer


public class MainActivity extends ListActivity  implements  Observer {
 
   protected void onCreate(Bundle savedInstanceState) {...}
 
    public void update(Observable o, Object arg) {
 
        Log.i("OBSERVER", "je suis dans update");
        méthode();
 
    }

public class Boite_De_Dialogue extends DialogFragment {
 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
        View v = inflater.inflate(R.layout.boite_de_dialogue, null);
 
        Button bouton = (Button) v.findViewById(R.id.idBouton);
        bouton.setOnClickListener(methodOnClick);
 
        return v;
   }
 
public class Observe extends Observable {
 
    public Observe ()
    {
 
        Log.i("JE_SUIS_DANS_OBSERVE","je suis dans observe");
        notifyObservers();
    }
 
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...