how to add images to tabs

I created tabs. Now i want to put some icons as background of that tabs. give me some sample code on that
Who is Participating?
If you mean to put the icons on the tabs themselves, then read:

If you want the images as backgrounds in the main area, in the onCreate() for a tab, put:

TextView textview = new TextView(this);
Resources res = this.getResources();
Drawable myImage = res.getDrawable(R.drawable.myimage);

where your image "myimage" is put in the drawable resource folder.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.