Java TabHost和异步任务存在问题
我有一个应用程序,它使用一个异步任务来挖掘一些HTML数据,在我尝试在我的应用程序上使用TabHost之前,它工作得很好。问题是,当我尝试打开此选项卡时,它会弹出ProgressDialog,但过了一会儿,它进入了Java TabHost和异步任务存在问题,java,android,android-asynctask,android-tabhost,Java,Android,Android Asynctask,Android Tabhost,我有一个应用程序,它使用一个异步任务来挖掘一些HTML数据,在我尝试在我的应用程序上使用TabHost之前,它工作得很好。问题是,当我尝试打开此选项卡时,它会弹出ProgressDialog,但过了一会儿,它进入了doInBackground方法中的一个catch,异常为null,而不是null点,只是e=null,并且不会使用挖掘中的数据设置适配器。下面是一些代码: onCreate(){ ... this.pd = ProgressDialog.show(this, "Downl
doInBackground
方法中的一个catch,异常为null,而不是null点,只是e=null
,并且不会使用挖掘中的数据设置适配器。下面是一些代码:
onCreate(){
...
this.pd = ProgressDialog.show(this, "Downloading..",
"Downloading...", true, false);
this.pd.setCanceledOnTouchOutside(false);
this.pd.setCancelable(true);
...
task = new DownloadTask().execute("Starting");
}
及
你知道为什么它会进入挡块吗?使用tabActivity时是否需要修改一些代码
提前谢谢
更新:
有时在调试时,我从entity.getContent()获得e=IllegalStateException,即使这是第一次被调用。还有StringOutOfBoundsException,因为内容没有获取正确的数据,我的意思是,没有它登录的选项卡,页面工作,但是有了tabHost它没有,tabHost对它有什么影响?得到了,是另一个活动传递给TabActivity的意图
private class DownloadTask extends AsyncTask<String, Void, Object> {
protected Object doInBackground(String... args) {
search = new Search(person);
try {
search.Login();
data = search.ParseData();
} catch (Exception e) {
erroUnknown = true;
}
adapter = new RowAdapter(DataActivity.this, data);
}
}
public class TabMenu extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, DataActivity.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost
.newTabSpec("data")
.setIndicator("Data",
res.getDrawable(R.drawable.ic_launcher))
.setContent(intent);
tabHost.addTab(spec);
//Just test
spec = tabHost
.newTabSpec("artists")
.setIndicator("Artists",
res.getDrawable(R.drawable.ic_launcher))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}