我想在选项卡上设置图标。我的代码是正确的,我确定。这是因为 android 版本的问题吗?我看了很多代码,但它们都是一样的。代码是;
package com.mesutemre.androidtabkullanimi;
import android.os.Bundle;
import android.app.Activity;
import android.app.ActivityGroup;
import android.app.TabActivity;
import android.content.Intent;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends TabActivity {
@SuppressWarnings("deprecation")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost tabhost = getTabHost();
tabhost.setup();
tabhost.addTab(tabhost
.newTabSpec("tabindis1")
.setIndicator("SEKME1",
getResources().getDrawable(R.drawable.document))
.setContent(new Intent(MainActivity.this, Sekme1Activity.class)));
tabhost.addTab(tabhost
.newTabSpec("tabindis2")
.setIndicator("SEKME2",
getResources().getDrawable(R.drawable.music))
.setContent(new Intent(MainActivity.this, Sekme1Activity.class)));
tabhost.addTab(tabhost
.newTabSpec("tabindis3")
.setIndicator("SEKME3",
getResources().getDrawable(R.drawable.delete))
.setContent(new Intent(MainActivity.this, Sekme1Activity.class)));
tabhost.addTab(tabhost
.newTabSpec("tabindis4")
.setIndicator("SEKME4",
getResources().getDrawable(R.drawable.close))
.setContent(new Intent(MainActivity.this, Sekme1Activity.class)));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
我从一些链接中读到这是一个问题 android 4.0 及更高版本。我该怎么做才能在选项卡上设置图标。