moosa_b
جمعه 11 مرداد 1392, 15:42 عصر
من میخواستم کد زیر رو اجرا کنم که این مشکل پیش اومد: (The type TabActivity is deprecated)
چیکار کنم؟
خودش میگه انو اضافه کن(("@SuppressWarnings("deprecation) اما نمیشه!
http://developer.android.com/resources/t...idget.html (http://developer.android.com/resources/tutorials/views/hello-tabwidget.html)
================================================== =====
import android.app.TabActivity; // - This is crossed in the middle
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;
public class DemonstratorActivity extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost(); // The activity TabHost - This is crossed in the middle
TabHost.TabSpec spec;
Intent intent;
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, DriveActivity.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("Tab1").setIndicator("Tab1",
res.getDrawable(R.drawable.Tab1picture))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, LightsControlActivity.class);
spec = tabHost.newTabSpec("Tab2").setIndicator("Tab2",
res.getDrawable(R.drawable.Tab2picture))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, NavigationActivity.class);
spec = tabHost.newTabSpec("Tab3").setIndicator("Tab3",
res.getDrawable(R.drawable.Tab3picture))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
}
چیکار کنم؟
خودش میگه انو اضافه کن(("@SuppressWarnings("deprecation) اما نمیشه!
http://developer.android.com/resources/t...idget.html (http://developer.android.com/resources/tutorials/views/hello-tabwidget.html)
================================================== =====
import android.app.TabActivity; // - This is crossed in the middle
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;
public class DemonstratorActivity extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost(); // The activity TabHost - This is crossed in the middle
TabHost.TabSpec spec;
Intent intent;
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, DriveActivity.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("Tab1").setIndicator("Tab1",
res.getDrawable(R.drawable.Tab1picture))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, LightsControlActivity.class);
spec = tabHost.newTabSpec("Tab2").setIndicator("Tab2",
res.getDrawable(R.drawable.Tab2picture))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, NavigationActivity.class);
spec = tabHost.newTabSpec("Tab3").setIndicator("Tab3",
res.getDrawable(R.drawable.Tab3picture))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
}