Forked from pipiscrew/imageview_adapter_interface.java
Last active
August 29, 2015 14:08
-
-
Save ks3dev/38d56171f933c410108c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //1-create an interface on separated class as : | |
| import java.util.EventListener; | |
| public interface post2socialInterface extends EventListener { | |
| public void responseResult(String val); | |
| } | |
| //2-at original class is like that : | |
| public class post2social { | |
| // Used to communicate the result back to the Activity | |
| public post2socialInterface listener; | |
| . | |
| . | |
| . | |
| //in a method raise the event like : | |
| listener.responseResult("Message posted on " + provider); | |
| . | |
| . | |
| . | |
| //make the setListener on your own! | |
| public void setListener(post2socialInterface listener) { | |
| this.listener = listener; | |
| } | |
| } | |
| //then at activity | |
| post2social s = new post2social(Test.this, "", "", "", "", "", ); | |
| s.setListener(new post2socialInterface() { | |
| @Override | |
| public void responseResult(String val) { | |
| final String tmp = val; | |
| runOnUiThread(new Runnable() { | |
| public void run() { | |
| if (progress != null) | |
| progress.dismiss(); | |
| Toast.makeText(TestActivity.this,tmp, Toast.LENGTH_LONG).show(); | |
| } | |
| }); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment