English 中文(简体)
在安康斯创建塔布特和增加陈列
原标题:Creating Tabhost and Adding specs from AsyncTask in Android

我正试图在其中制造一个禁忌和幽灵,但这是我需要做的一件事,这样它就没有行动。 在适用这一法典后,我只看到我的主要布局。 归根结底,I wanna向使用者展示了进步障碍,用户说,一旦安装申请,就首次复制了必要的档案,而平均时间拷贝文件则制造了表象并添加了光谱。 如果没有一个星号,它的工作非常好,但第一次提出申请后,屏幕被锁定20或30秒,直到复制过程完成。 任何想法? 提前感谢。

public class AsyncTest extends AsyncTask<Void, Void, Void> {

Context context;
DataBaseJSONFunctions json;

TabHost tabHost;

TabWidget tabWidget;

Resources res;

TabHost.TabSpec sp;

Intent intent;

ProgressDialog dialog;

Activity ac;

public AsyncTest(Context context, TabHost tabHost, TabHost.TabSpec sp, Bundle savedInstanceState) {
    this.context = context;
    json = new DataBaseJSONFunctions(context);
    this.tabHost = tabHost;
    tabWidget = tabHost.getTabWidget();
    this.sp = sp;
    ac = (Activity) context;
    res = context.getResources();

    LocalActivityManager mlam = new LocalActivityManager(ac, false);
    mlam.dispatchCreate(savedInstanceState);
    tabHost.setup(mlam );

}

@Override
protected Void doInBackground(Void... params) {
    initializeAll();
    return null;
}

@Override
protected void onPostExecute(Void result) {

    dialog.dismiss();

    // to go through to the another activity in the tab I need to initialize an intent.
    // and I need to set the Tab bar and it s icon.
    intent = new Intent().setClass(ac, Activities.class);
    sp = tabHost.newTabSpec("activities").setIndicator("activities",res.getDrawable(R.drawable.tab_activities_selector)).setContent(intent);
    tabHost.addTab(sp);

    // doing the same things for Songs Activity.
    intent = new Intent().setClass(ac, Promotions.class);
    sp = tabHost.newTabSpec("promotions").setIndicator("promotions",res.getDrawable(R.drawable.tab_promotions_selector)).setContent(intent);
    tabHost.addTab(sp);


    // doing the same things for another Activity.
    intent = new Intent().setClass(ac,Menu.class);
    sp = tabHost.newTabSpec("menu").setIndicator("Menu",res.getDrawable(R.drawable.tab_menu_selector)).setContent(intent);
    tabHost.addTab(sp);


    intent = new Intent().setClass(ac, Gallery.class);
    sp = tabHost.newTabSpec("gallery").setIndicator("Gallery",res.getDrawable(R.drawable.tab_gallery_selector)).setContent(intent);
    tabHost.addTab(sp);


    intent = new Intent().setClass(ac, Info.class);
    sp = tabHost.newTabSpec("info").setIndicator("Info",res.getDrawable(R.drawable.tab_info_selector)).setContent(intent);
    tabHost.addTab(sp);

    for(int i = 0; i < tabWidget.getChildCount(); i++){
        tabWidget.getChildAt(i).setBackgroundResource(R.drawable.tab_bar);
    }

    tabHost.setCurrentTab(0);

    // Starting location listener service.
    ac.startService(new Intent(ac, LocationService.class));

    ac.setContentView(R.layout.tabbar_main);
    super.onPostExecute(result);
}

@Override
protected void onPreExecute() {
    dialog = ProgressDialog.show(context, "", "Copying files please wait...");
    super.onPreExecute();
}
最佳回答

I have found the way to do it, I have an image view which has visibility as GONE and In the onPreExecute() I m setting the visibility of this image as VISIBLE. and Also onPostExecute() I m making it GONE as like before.

问题回答

for tab layout your xml should b like this;

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" />

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0" />
        </LinearLayout>
    </TabHost>


</RelativeLayout>




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签