> 백엔드 개발 > C#.Net 튜토리얼 > Android 애플리케이션 개발을 위한 C# + Xamarin --- Tab 구현

Android 애플리케이션 개발을 위한 C# + Xamarin --- Tab 구현

黄舟
풀어 주다: 2017-03-01 10:33:56
원래의
1993명이 탐색했습니다.

레이아웃:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"

    android:id="@android:id/tabhost"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent">

    <LinearLayout

        android:orientation="vertical"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:padding="5dp">

        <TabWidget

            android:id="@android:id/tabs"

            android:layout_width="fill_parent"

            android:layout_height="wrap_content" />

        <FrameLayout

            android:id="@android:id/tabcontent"

            android:layout_width="fill_parent"

            android:layout_height="fill_parent"

            android:padding="5dp" />

    </LinearLayout>

</TabHost>

로그인 후 복사

액티비티(TabActivity에서 상속됨):

CreateTab 메소드 생성

1

2

3

4

5

6

7

8

9

10

11

12

13

14

private void CreateTab(Type activityType, string tag, string label, int drawableId)

        {

            var intent = new Intent(this, activityType);

            intent.AddFlags(ActivityFlags.NewTask);

 

 

            var spec = TabHost.NewTabSpec(tag);

            var drawableIcon = Resources.GetDrawable(drawableId);

            spec.SetIndicator(label, drawableIcon);

            spec.SetContent(intent);

 

 

            TabHost.AddTab(spec);

        }

로그인 후 복사

두 개의 탭 생성

1

2

CreateTab(typeof(BusinessSearch), "Search", "Search", Resource.Drawable.abc_ab_share_pack_mtrl_alpha);

           CreateTab(typeof(MyOrders), "My Orders", "My Orders", Resource.Drawable.abc_btn_check_material);

로그인 후 복사

위는 C# + Xamarin은 Android 애플리케이션을 개발합니다---탭 구현 내용에 대한 자세한 내용은 PHP 중국어 웹사이트(www.php.cn)를 참고하세요!


관련 라벨:
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿