标签:java os ar art new res on sp
---------------------------
//设置回调接口的Fragment public class TestFragment extends Fragment { //启动异步任务 private void methodThatStartsTheAsyncTask() { TestAsyncTask testAsyncTask = new TestAsyncTask(new FragmentCallback() { @Override public void onTaskDone() { methodThatDoesSomethingWhenTaskIsDone(); } }); } private void methodThatDoesSomethingWhenTaskIsDone() { //异步任务完成后的操作 } public interface FragmentCallback { public void onTaskDone(); } }
-----------------------------------------------------
public class TestAsyncTask extends AsyncTask<Void, Void, Void> { private FragmentCallback mFragmentCallback; public TestAsyncTask(FragmentCallback fragmentCallback) { mFragmentCallback = fragmentCallback; } @Override protected Void doInBackground(Void... params) { /* * Do your thing. */ return null; } @Override protected void onPostExecute(Void result) { mFragmentCallback.onTaskDone(); } }
Callback AsyncTask to Fragment,布布扣,bubuko.com
Callback AsyncTask to Fragment
标签:java os ar art new res on sp
原文地址:http://my.oschina.net/arunu/blog/300430