こんにちは、TabHosts を Progress Dialog で動作させようとしていますが、それぞれのアクティビティで ListView をロードするとこれらのエラーが発生し続けますが、これらのエラーが発生し続けます。
コード:
public class AndroidTabLayoutActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//final ProgressDialog dialog = ProgressDialog.show(getParent(), "Please wait..", "Doing stuff..", true);
final ProgressDialog pd = new ProgressDialog(this);
pd.setMessage("Please wait...");
pd.show();
Runnable myRun = new Runnable(){
public void run(){
Looper.myLooper().prepare();
//DO EVERYTHING YOU WANT!
TabHost tabHost = getTabHost();
// Tab for All
TabSpec allspec = tabHost.newTabSpec("All");
allspec.setIndicator("All", getResources().getDrawable(R.drawable.icon_photos_tab));
Intent allIntent = new Intent(AndroidTabLayoutActivity.this, AllApplicationsActivity.class);
allspec.setContent(allIntent);
// Tab for Installed Application
TabSpec systemspec = tabHost.newTabSpec("Installed Applications");
// setting Title and Icon for the Tab
systemspec.setIndicator("Applications", getResources().getDrawable(R.drawable.icon_videos_tab));
Intent systemIntent = new Intent(AndroidTabLayoutActivity.this, SystemApplicationsActivity.class);
systemspec.setContent(systemIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(allspec);
tabHost.addTab(systemspec);
//Finally
runOnUiThread(new Runnable() {
public void run() {
pd.dismiss();
}
});
}
};
Thread T = new Thread(myRun);
T.start();
}
}
編集:プログラムを起動するとエラーが発生するようになりました
07-26 17:55:05.637: E/AndroidRuntime(25603): FATAL EXCEPTION: Thread-974
07-26 17:55:05.637: E/AndroidRuntime(25603): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4286)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:885)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.view.View.requestLayout(View.java:12881)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.view.View.requestLayout(View.java:12881)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.view.View.requestLayout(View.java:12881)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.view.View.requestLayout(View.java:12881)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.view.View.requestLayout(View.java:12881)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.view.View.requestLayout(View.java:12881)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.view.ViewGroup.addView(ViewGroup.java:3211)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.view.ViewGroup.addView(ViewGroup.java:3193)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.widget.TabHost.setCurrentTab(TabHost.java:349)
07-26 17:55:05.637: E/AndroidRuntime(25603): at android.widget.TabHost.addTab(TabHost.java:236)
07-26 17:55:05.637: E/AndroidRuntime(25603): at com.example.androidtablayout.AndroidTabLayoutActivity$1.run(AndroidTabLayoutActivity.java:43)
07-26 17:55:05.637: E/AndroidRuntime(25603): at java.lang.Thread.run(Thread.java:856)
07-26 17:55:05.927: D/OpenGLRenderer(25603): Flushing caches (mode 0)
07-26 17:55:05.967: D/OpenGLRenderer(25603): Flushing caches (mode 0)
07-26 17:55:29.132: D/OpenGLRenderer(25603): Flushing caches (mode 2)
07-26 17:55:29.372: D/AndroidRuntime(25603): Shutting down VM