TabActivity类型已弃用 [英] The type TabActivity is deprecated

查看:546
本文介绍了TabActivity类型已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Android应用中创建标签,我正在做一个在这里找到的教程



http://developer.android.com/resources/tutorials/views/hello-tabwidget.html [ ^ ]



但不知道TabActivity并采取这个解决方案:@SuppressWarnings(弃用)!!



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[^]

but unknow the TabActivity and take this solution: @SuppressWarnings("deprecation")!!
?

<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;
 
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);
	    }
	}</code>

推荐答案

这实际上不是问题。这只是一个警告,告诉您正在使用的对象已被弃用。这并不意味着您不能再使用该对象。
It's not actually an issue. It's just a warning telling you that the object you are using has already been deprecated. It does not mean that you cannot use the object anymore.


这篇关于TabActivity类型已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆