마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Tabhost 의 액션바에 이미지를 넣는 방법을 알고싶습니다. [closed]

0 추천
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <TabHost
        android:id="@+id/tabHost"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView
                    android:id="@+id/Image1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/cat2" />

                <ImageView
                    android:id="@+id/Image2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/dog2" />

                <ImageView
                    android:id="@+id/Image3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/horse2" />

                <ImageView
                    android:id="@+id/Image4"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/rabbit2" />
            </FrameLayout>
        </LinearLayout>
    </TabHost>
</LinearLayout>

 

package com.cookandroid.chapter6_practice7;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TabHost;

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TabHost tabHost = (TabHost)findViewById(R.id.tabHost);
        tabHost.setup();

        TabHost.TabSpec spec = tabHost.newTabSpec("tag1");
        spec.setContent(R.id.Image1);
        spec.setIndicator("tab1");
        tabHost.addTab(spec);

        spec = tabHost.newTabSpec("tag2");
        spec.setContent(R.id.Image2);
        spec.setIndicator("tab2");
        tabHost.addTab(spec);

        spec = tabHost.newTabSpec("tag3");
        spec.setContent(R.id.Image3);
        spec.setIndicator("tab3");
        tabHost.addTab(spec);

        spec = tabHost.newTabSpec("tag4");
        spec.setContent(R.id.Image4);
        spec.setIndicator("tab4");
        tabHost.addTab(spec);
    }
}

 

위의 xml과 java 작성으로 탭을 누르면 동물이 바뀌게 만들었습니다.

여기에 위에 TAB1, TAB2, TAB3, TAB4 로 적혀있는 글자를 없애고 이미지를 넣고싶습니다.

이곳저곳 찾아보고 있는데 어떻게 해야할지 잘 감이 안오네요.

이미지랑 글자를 같이 넣는게 아니라 순수하게 이미지로만 탭을 만들고싶습니다.

도움을 주시면 감사하겠습니다.

질문을 종료한 이유: 문제 해결
짜쿠사냥 (160 포인트) 님이 2017년 11월 5일 질문
짜쿠사냥님이 2017년 11월 5일 closed
...