I want to set icon on a tab. My codes are right and I am sure.Is it a problem because of the version of android? I looked lots of codes but all of them are the same.The codes are;
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;
}
}
I read from some links that this is a problem adroid 4.0 and later. What can i do for setting icon on a tab.
Pls try setView to set TextView instead of setIndicator. Set icon and indicator text to TextView.