0

タブのコンテンツとしてアクティビティを設定した tabActivity があります。アクティビティから、タブホストを無効にしようとしています。これを達成する方法。

  public class Main extends TabActivity {

public static final File sdcard = Environment.getExternalStorageDirectory();

 @Override
   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    TabHost tabHost = getTabHost();

    TabSpec homespec = tabHost.newTabSpec("Home");
    homespec.setIndicator("Home");
    Intent homeIntent = new Intent(this, HomeActivity.class);
    homespec.setContent(homeIntent);

    TabSpec presentspec = tabHost.newTabSpec("Presentations");
    presentspec.setIndicator("Presentations");
    Intent presentIntent = new Intent(this, PresentationActivity.class);
    presentspec.setContent(presentIntent);

    TabSpec pendspec = tabHost.newTabSpec("Pending Submission");
    pendspec.setIndicator("Pending Submission" /*getResources().getDrawable(R.drawable.icon_videos_tab)*/);
    Intent pendingIntent = new Intent(this, PendingActivity.class);
    pendspec.setContent(pendingIntent);

    TabSpec syncspec = tabHost.newTabSpec("Synchronization");
    syncspec.setIndicator("Synchronization" /*getResources().getDrawable(R.drawable.icon_videos_tab)*/);
    Intent syncIntent = new Intent(this, SyncActivity.class);
    syncspec.setContent(syncIntent);

    tabHost.addTab(homespec); 
    tabHost.addTab(presentspec); 
    tabHost.addTab(pendspec);
    tabHost.addTab(syncspec);


}
}

これは私のtbb活動です

  public class SyncActivity extends Activity {
     class DownloadWebPageTask extends AsyncTask<String, Void, String> {

                   @Override
        protected void onPostExecute(String result) {
            end();
        }

        @Override
        protected String doInBackground(String... params) {

              progress.setVisibility(ProgressBar.VISIBLE);
              progress.setProgress(0);
              progress.setMax(1000);

            int currentPosition= 0;

            while (currentPosition<1000) {
                try {
                    Thread.sleep(500);
                    currentPosition+=100;
                } catch (InterruptedException e) {
                    return null;
                } catch (Exception e) {
                    return null;
                }            
                progress.setProgress(currentPosition);

            }
            return null;
        }
      }
    }

これを試している間、他のタブは無効にする必要があります

4

1 に答える 1

0

TabActivity は廃止されました。タブとフラグメントを試してください。詳細については、こちらを参照してください。

ブール値フラグを使用して有効なタブを処理できます。まずタブを変更しようとすると、タブがアクティブかどうかを確認できます。

于 2012-11-22T13:32:31.507 に答える