android - Call a method in MainActivity.java on event that happens in a library file -


itemprop = "text">

I included the library in my Android project In the mainActvitiy.java, the onCreate method contains something like this:

  SimpleCardStackAdapter adapter = new simple cardstock adapter (this); // This library should also be done on an event in class: adapter.add (new cardmodel ("Heading 2", "Description 2 goes here", R.ZDraravable (Arrowable Picture 2));  

Now, in CardContainer.java (which is related to the swipeable card library) is an event on which I have a new item adapter adapter.add (. ..) . The adapter was defined in mainactivity.java as you can see above. How can I get it?

I first thought about defining a new method in main activity and then calling it from its library category, like:

  Public Zero Call Frame Library () {Adapter.add (...); }  

However, the method and adapters need to define static, except that I do not know how to make this method of main activity available in CardContainer.java.

I believe that I need to create a kind of listener to check the menactivity that happens in CardContainer. I do not know how to do this.

Any help is appreciated!

card dialogue to communicate by main activity For, you can define an interface in cardcontainer and implement it in MainActivity . This event occurs in CardContainer , when it can call the interface method to add the adapter to cardmodel .

  Public class card container extends ... {CardContainer Event Listener M-Mailback; // Define an Interface Public Interface CardContainerEventListener {Public Zero AddToAdapter (); } // Callback Request Register method to register callback {activity callback} {mCallback = (CardContainer Event Listener) Callback; } Some functions (nothing less) than {//}, callback method mCallback.addToAdapter (); }} The implementation of public class main activity activity cardcountainer is spread. Cardcontainer listener {// Make sure you register the main activity with CardContainer, // Card Container. Call the registrar callback (this), AdoAdapter () {adapter.add (...); }}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -