问题描述
我正在尝试在android应用中创建标签页,并且正在做一个教程,可在此处找到
http://developer.android.com/resources/tutorials/views/hello-tabwidget.html [^ ]
而且我完全正确地遵循了它,但是程序运行了1秒钟,然后说它停止了.我不知道我在做什么.错误是在此页面中,它说的是-@supressWarnings("deprecation")我不知道为什么.任何人都可以帮忙吗?也许任何已经关注本教程的人?
这是我的代码:
i am trying to create tabs in an android app, and i am doing a tutorial which is found in here
http://developer.android.com/resources/tutorials/views/hello-tabwidget.html[^]
and i followed it accuratly, but the program is running for 1 second and then saying that it stopped. I don''t know what i am doing wrond. the error is in this page as it is saying - @supressWarnings("deprecation") i dont know why. Please can anyone help? maybe anyone who already followed this tutorial?
this is my code:
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;
@SuppressWarnings("deprecation")
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);
}
}
推荐答案
这篇关于使用Android应用程序创建标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!