我正在使用AsyncTask和一些非常常见的Android代码来获取远程网页的内容.根据返回的内容,我可以调用另一个页面.
http://developer.android.com/reference/android/os/AsyncTask.html
我的调试行应该像这样打印:
1> StartA()
2> onPreExecute
3> doInBackground
4> onPostExecute Note: Code here will call EndA()
5> EndA()
6>
7> StartB()
8> onPreExecute
9> doInBackground
10> onPostExecute Note: Code here will call EndB()
11> EndB()
Run Code Online (Sandbox Code Playgroud)
这不可能吗?我得到了以上所有内容...除了我在第8行和第9行之间出现一个对EndB()的附加调用.
我不能为我的生活找出原因.没有什么看起来应该两次调用EndB().它绝对不应该在9和10之前被称为.
private void StartA()
{
Debug("StartA()");
g_GetWhat = 1;
DownloadWebPageTask task = new DownloadWebPageTask();
task.execute(new String[] { "http://google.com" });
}
private void EndA()
{
Debug("EndA()");
StartB();
}
private void StartB()
{
Debug("StartB()");
g_GetWhat = 2;
DownloadWebPageTask task = new DownloadWebPageTask();
task.execute(new String[] { …Run Code Online (Sandbox Code Playgroud) 我正在使用以下(非常常见的)代码来更改我的 Android 应用程序中的复选框图像。
mCheck = (CheckBox) findViewById(R.id.chkMine);
mCheck.setButtonDrawable(R.drawable.my_image);
Run Code Online (Sandbox Code Playgroud)
我看到很多人要求这样做。但我从来没有看到第二部分:
How do I put BACK the original checkbox imagery, later in my code?
Run Code Online (Sandbox Code Playgroud)
我犹豫要不要尝试设计我自己的所有图像(选中、未选中、重影选中、重影未选中等),因为我需要通常会出现在许多不同版本的 Android 上的原始图像。
也许,最初使用(不存在?)getButtonDrawable() 调用保存默认图像,然后再重用它?
我认为这就像第二次调用 setButtonDrawable() 来“撤消”我的更改一样简单。或者是吗?
谢谢。