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

탭호스트로 값을 넘겨서 특정 탭에 지정되게 하고 싶습니다.

0 추천

 

안녕하세요.

인텐트의 값전달에 따른, 탭호스트의 특정 위치로 이동시켜주는 부분에 대해서 고민입니다.

// 특정 탭의 위치로 이동시켜주는 구문임
tab_host.setCurrentTab(1);

현재 아래는 Location 이라는 자바 파일에서 버튼을 눌렀을 경우에, 탭호스트가 있는 Location_and_seat.class로 인

텐트를 하는 문장입니다. 그런데, 그냥 인텐트를 호출하는것이 아니라,  숫자1을 보냄을 알수가 있습니다.

그 이유는 Location_and_Seat 부분에 탭호스트가 0~2까지 지정되어있고, 아래의 버튼을 통해서 이동하게 되었을때

0~2까지 구성되어있는 탭의 버튼중 첫번째 탭부분으로 이동이 되게 하려고 의도했습니다.

 

Location_Selection_Btn = (Button) findViewById(R.id.Loation_Selection);
Location_Selection_Btn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {

        int tabindex= 1;

        Intent intent = new Intent(getBaseContext(),Location_and_Seat.class);
        intent.putExtra("Tab_Selection",tabindex);
        startActivity(intent);

    }
});

 

< 아래소스는 Location_and_Seat파일의 Oncreate 아래부분>

int Tab_Index = getIntent().getIntExtra("Tab_Selection",0);
if(Tab_Index==1)
{
    // 특정 탭의 위치로 이동시켜주는 구문임
    tab_host.setCurrentTab(1);

}
else
{
    tab_host.setCurrentTab(0);
}

@@

***************************

 

 

 

 

 

 

Kind카인드 (3,600 포인트) 님이 2016년 11월 29일 질문
Kind카인드님이 2016년 12월 7일 수정

1개의 답변

0 추천
 
채택된 답변

아래 코드가 삽입된 함수(Method) 전체 코드를 작성해주세요

그리고, 아래 코드는 굳이 if 문으로 구분할 필요없이 아래 한줄로 처리하는 것이 좋겠네요. 

tab_host.setCurrentTab(Tab_Indec2);

if(Tab_Index2==2)
{
    // 특정 탭의 위치로 이동시켜주는 구문임
    tab_host.setCurrentTab(2);

}
else
{
    tab_host.setCurrentTab(0);
}
빅배스 (4,260 포인트) 님이 2016년 11월 29일 답변
Kind카인드님이 2016년 11월 30일 채택됨
빅베스님 제가 원글의 아래쪽에 제가 만들고자 하는 사진에 대해서 한번
올려보았습니다. 왼쪽 상단의 검은색 미니화면에, 텍스트뷰에 대한 그림이
어느정도 나와있길래.. 저도 저렇게 구현을 하고 싶은데 줌뷰 관련해서 찾아보아도 미니맵에 액티비티를 표현하는게 쉽게 나오질 않네요 ..

제가 잘 못찾는건지.. 아니면 정보가 없는건지.. (그럴리는없겠지만..ㅜㅡ ㅜ)

저는 최대한 똑같은 라이브러리를 발견했다고 생각했는데 그게 아닌건가
싶기도 하네요 ..

제가 사실 제가 쓴 글 원본의 아래쪽에 있는 사진을 보고 목표로 삼아서
만들고 있었는데 확대도 되고, 미니맵도 뜨는데 화면에 저 액티비티를
못띄워서 단순히 확대밖에 안되네용.. 으흑흑

좀 더 찾아보다가 정 안된다면..

그냥 확대로라도 쓰던지 아니면 다른 라이브러리를 찾아보아야 할것같은데..

여기저기 물어보았지만 라이브러리에 대해서 제가 이번에 처음 적용을

시켜보는거라서, 그래도 좋은 경험이 되었어용 ㅋㅋ

도움을 많이 받았지만 그래도 거의 가까워져 간다고 생각했었는데,,

기존의 좌석들의 이미지를 크게 만들어서, 위의 사진과 같이

넓고 큼지막하게 할텐데 쫌 아쉽네염ㅜ
빅배스님 ㅠ  뭐좀 하나 여쭤보아도 될까용 ㅜ ㅜ
아무래도 Kind 님이 찾은 라이브러리로는 안될것 같네요
아쉬워도 일단 그정도로 만족하셔야 될 것같습니다.
아..물론 질문하세요~~ ㅎ
네 ㅠ 몇날며칠 찾아봐도, 그냥 확대되는 기능으로만 마무리 지으려고 합니다.

궁금한점이 .. 다름이 아니라 , 제가 원글의 아래쪽에 사진을 달아 보았는데..

2번째 사진에서 보면, 맨 위쪽의 툴바에 보면, 일반0, 청소년3, 우대2 가

나타납니다. 이 툴바가, 첫번째 화면에서 눌렀던것이 나타나고 선택완료를

누르게 되면, 뒤쪽에 가장 위쪽에 나타나는데, 이 부분이 첫번쨰 화면에서

맨위쪽에도 나타나게 하고 싶은데 그 방법을 모르겠습니다.

첫 화면에서 입력받는 부분의 시작부터 선택완료 버튼 부분까지는 아래와

같습니다.

일반과 청소년, 우대로 포함된 텍스트뷰의 xml 아래와 같고

<RelativeLayout
        android:id="@+id/choiii"
        android:background="#77000000"
        android:layout_width="match_parent"
        android:visibility="visible"
        android:layout_height="match_parent">


선택완료로 끝나는 부분은 아래와 같습니다.

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="40dp"
            android:background="#ffffff"
            android:layout_below="@+id/Senior_Layout">

            <Button
                android:id="@+id/Selection_Success"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="선택완료"
                android:background="#c300ff"
                android:textColor="#ffffff"
                />

        </LinearLayout>


그리고, 선택완료를 누르게 되면 시작부분의 choiii 부분이 Visibility가

gone이 되어 사라집니다.

그리고 선택완료를 누르게 되고 난 화면의 맨 위쪽에 있는 툴바의 소스는ㅠ 아래와 같습니다.

스크롤뷰 아래 아래에 있는 Seat_ToolBar 부분인데.. 어떻게 해야, 앞쪽의 화면에도 나타나게 할 수 있을까요 ..ㅠ




<ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <RelativeLayout
            android:id="@+id/Before_ScrollView_RelativeLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <RelativeLayout
                android:id="@+id/Seat_Toolbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp">

                <ImageView
                    android:id="@+id/Seat_Before_Image"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:layout_marginBottom="3dp"
                    android:layout_marginLeft="3dp"
                    android:background="@drawable/before_image" />

                <TextView
                    android:id="@+id/Adult_number"
                    android:text="0"
                    android:layout_marginLeft="100dp"
                    android:textSize="25dp"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

                <TextView
                    android:id="@+id/Adult_textview"
                    android:layout_below="@+id/Adult_number"
                    android:layout_width="wrap_content"
                    android:text="일반"
                    android:layout_marginLeft="90dp"
                    android:textSize="15dp"
                    android:layout_height="wrap_content" />
<TextView
                    android:id="@+id/School_number"
                    android:text="0"
                    android:textSize="25dp"
                    android:layout_marginLeft="200dp"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

                <TextView
                    android:id="@+id/School_textview"
                    android:layout_below="@+id/School_number"
                    android:layout_width="wrap_content"
                    android:text="청소년"
                    android:textSize="15dp"
                    android:layout_marginLeft="180dp"
                    android:layout_height="wrap_content" />

                <TextView
                    android:id="@+id/Senior_number"
                    android:text="0"
                    android:textSize="25dp"
                    android:layout_marginLeft="300dp"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

                <TextView
                    android:id="@+id/Senior_textview"
                    android:layout_below="@+id/Senior_number"
                    android:layout_width="wrap_content"
                    android:text="우대"
                    android:textSize="15dp"
                    android:layout_marginLeft="290dp"
                    android:layout_height="wrap_content" />


            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/screen_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/Seat_Toolbar"
                android:orientation="horizontal"
                android:layout_marginTop="10dp"
                android:background="@drawable/screen">

            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/entrance_layout"
                android:layout_below="@+id/screen_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <ImageView
                    android:id="@+id/right_entrance"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/entrance"
                    android:layout_alignParentTop="true"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentEnd="true" />

                <ImageView
                    android:id="@+id/left_entrance"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/entrance"
                    android:layout_alignParentTop="true"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true" />

            </RelativeLayout>


            <RelativeLayout
                android:id="@+id/seat_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>



            <LinearLayout
                android:id="@+id/Handicapped_Layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="60dp"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:background="#ff8400"
                android:layout_below="@+id/seat_layout"
                android:orientation="horizontal">

                <ImageView
                    android:id="@+id/Check_Box_Img"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:background="@drawable/box_image"/>

                <TextView
                    android:id="@+id/General_Seat_textview"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="25dp"
                    android:textStyle="bold"
                    android:layout_marginLeft="20dp"
                    android:text="일반석"/>


                <ImageView
                    android:id="@+id/Handicapped_Check_Box_Img"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:background="@drawable/handicapped_checkbox_img"/>

                <TextView
                    android:id="@+id/Handicapped_Seat_textview"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="25dp"
                    android:layout_marginLeft="20dp"
                    android:textStyle="bold"
                    android:text="장애인석"/>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/Seat_Pay_Layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/Handicapped_Layout"
                android:weightSum="4"
                android:background="#00000000"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/Seat_Pay_Money"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_marginLeft="10dp"
                    android:text="결제 금액"/>


                <TextView
                    android:id="@+id/Total_Movie_Money"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:layout_weight="2"
                    android:textSize="20dp"
                    />


                <Button
                    android:id="@+id/Seat_SelectionAccess_Button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="#7b00ff"
                    android:text="선택완료"/>

            </LinearLayout>

        </RelativeLayout>

    </ScrollView>
...