android studio 考试系统

<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"
    tools:context=".MainActivity" >
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />
    <TabHost
        android:id="@+id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <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" >
            </TabWidget>

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

                <!-- 第一个tab的布局 -->
                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <TextView
                        android:id="@+id/textView1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="java属于以下哪种语言" />
                    <RadioGroup
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <RadioButton
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="A、机器语言">
                        </RadioButton>

                        <RadioButton
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="B、汇编语言">
                        </RadioButton>

                        <RadioButton
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="C、高级语言">
                        </RadioButton>

                        <RadioButton
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="D、以上都不是">
                        </RadioButton>
                    </RadioGroup>
                </LinearLayout>

                <!-- 第二个tab的布局 -->
                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/textView2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="你的爱好有" />
                    <CheckBox
                        android:text="A、篮球"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"/>
                    <CheckBox
                        android:text="B、足球"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"/>
                    <CheckBox
                        android:text="C、游泳"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"/>
                    <CheckBox
                        android:text="D、排球"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"/>

                </LinearLayout>

                <!-- 第三个tab的布局 -->
                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <TextView
                        android:id="@+id/textView3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="调用sleep()方法可以使一个线程停止运行" />
                    <RadioGroup
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <RadioButton
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="正确">
                        </RadioButton>

                        <RadioButton
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="错误">
                        </RadioButton>
                    </RadioGroup>
                </LinearLayout>
                <!-- 第四个tab的布局 -->
                <LinearLayout
                    android:id="@+id/tab4"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <TextView
                        android:id="@+id/textView4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Java的权限修饰符有哪些" />
                    <EditText
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>

</LinearLayout>

package com.example.kaoshixitong3;

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

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TabHost th=(TabHost)findViewById(R.id.tabhost);
        th.setup();            //初始化TabHost容器

        //在TabHost创建标签,然后设置:标题/图标/标签页布局
        th.addTab(th.newTabSpec("tab1").setIndicator("单选",null).setContent(R.id.tab1));
        th.addTab(th.newTabSpec("tab2").setIndicator("多选",null).setContent(R.id.tab2));
        th.addTab(th.newTabSpec("tab3").setIndicator("判断",null).setContent(R.id.tab3));
        th.addTab(th.newTabSpec("tab4").setIndicator("填空",null).setContent(R.id.tab4));
        //上面的null可以为getResources().getDrawable(R.drawable.图片名)设置图标

    }
}

  • 0
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值