Android常用控件

Button

属性:onClick=“方法名”
页面 Activity中,定义方法,方法参数View类型
事件:setOnClickListener(new OnClickListener()){重写onClick方法}
页面实现OnClickListener接口,重写onClick()方法{switch(v.getId() case R.id.XXX:break;)}

textView

属性:text设置文本
textSie:字体的大小 单位sp
textColor:字体的颜色
typeface:字体(黑体)
textstyle:样式(常规,加粗,倾斜)
lines:行数
singleLine:单行

跑马灯:android:ellipsize=“marquee” 让多的字轮播
android:singleLine=“true” 只显示一行
android:focusableInTouchMode=“true” 点击时也要获得焦点
android:focusable=“true” 页面开启时要获得焦点

EditText 文本输入框

属性:hint 默认提示文本
inputType 文本类型
maxLength 文本最大长度

代码实现

// An highlighted block
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".allActivity"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/activityall"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="5"
        android:visibility="visible">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

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

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#F9F9F9">

                        <ImageView
                            android:id="@+id/xiaoshi"
                            android:layout_width="50dp"
                            android:layout_height="match_parent"
                            android:src="@mipmap/jiantou"/>
                        <TextView
                            android:layout_width="100dp"
                            android:layout_height="match_parent"
                            android:text="订单详情"
                            android:textSize="25dp"
                            android:layout_marginLeft="50dp"
                            android:layout_marginTop="4dp"/>
                        <ImageView
                            android:layout_width="20dp"
                            android:layout_height="20dp"
                            android:src="@mipmap/dian1"
                            android:layout_marginLeft="360dp"/>
                        <TextView
                            android:layout_width="100dp"
                            android:layout_height="match_parent"
                            android:text=":"
                            android:textSize="30dp"
                            android:layout_marginLeft="360dp"
                            android:layout_marginTop="4dp"
                            />

                    </RelativeLayout>

                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1.7">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:layout_width="60dp"
                            android:layout_height="22dp"
                            android:text="商品总价"
                            android:layout_marginTop="8dp"
                            android:textSize="12dp"
                            android:layout_marginLeft="9dp"/>
                        <TextView
                            android:layout_width="60dp"
                            android:layout_height="22dp"
                            android:text="运费(快递)"
                            android:layout_marginTop="22dp"
                            android:textSize="12dp"
                            android:layout_marginLeft="9dp"/>
                        <TextView
                            android:layout_width="100dp"
                            android:layout_height="22dp"
                            android:text="运费险(卖家赠送)"
                            android:layout_marginTop="36dp"
                            android:textSize="12dp"
                            android:layout_marginLeft="9dp"/>
                        <TextView
                            android:layout_width="65dp"
                            android:layout_height="22dp"
                            android:text="订单总价"
                            android:layout_marginTop="55dp"
                            android:textSize="16dp"
                            android:layout_marginLeft="9dp"/>


                        <TextView
                            android:layout_width="60dp"
                            android:layout_height="22dp"
                            android:text="¥298.00"
                            android:layout_marginTop="8dp"
                            android:textSize="12dp"
                            android:layout_marginLeft="309dp"/>
                        <TextView
                            android:layout_width="60dp"
                            android:layout_height="22dp"
                            android:text="¥0.00"
                            android:layout_marginTop="22dp"
                            android:textSize="12dp"
                            android:layout_marginLeft="310dp"/>
                        <TextView
                            android:layout_width="100dp"
                            android:layout_height="22dp"
                            android:text="¥0.00"
                            android:layout_marginTop="36dp"
                            android:textSize="12dp"
                            android:layout_marginLeft="310dp"/>
                        <TextView
                            android:layout_width="65dp"
                            android:layout_height="22dp"
                            android:text="¥62.00"
                            android:layout_marginTop="55dp"
                            android:textSize="16dp"
                            android:layout_marginLeft="309dp"/>

                    </RelativeLayout>

                </LinearLayout>
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1.7">

                    <TextView
                        android:layout_width="65dp"
                        android:layout_height="22dp"
                        android:text="支付明细"
                        android:layout_marginTop="6dp"
                        android:textSize="12dp"
                        android:layout_marginLeft="309dp"/>

                    <TextView
                        android:layout_width="60dp"
                        android:layout_height="20dp"
                        android:text="天猫积分"
                        android:layout_marginTop="26dp"
                        android:layout_marginLeft="8dp" />

                    <TextView
                        android:layout_width="60dp"
                        android:layout_height="25dp"
                        android:text="实付款"
                        android:layout_marginTop="46dp"
                        android:layout_marginLeft="8dp"
                        android:textSize="19dp"/>

                    <TextView
                        android:layout_width="60dp"
                        android:layout_height="20dp"
                        android:text="-¥7.22"
                        android:layout_marginTop="26dp"
                        android:layout_marginLeft="308dp" />

                    <TextView
                        android:layout_width="60dp"
                        android:layout_height="25dp"
                        android:text="¥54.78"
                        android:layout_marginTop="46dp"
                        android:layout_marginLeft="300dp"
                        android:textSize="19dp"
                        android:textColor="#FF5001"/>

                </RelativeLayout>
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1.7"
                    android:background="#FFFFFF">

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="2dp">
                    </View>

                    <ImageView
                        android:layout_width="50dp"
                        android:layout_height="30dp"
                        android:src="@mipmap/jifen"
                        android:layout_marginLeft="10dp"
                        android:layout_marginTop="4dp"/>
                    <TextView
                        android:layout_width="80dp"
                        android:layout_height="20dp"
                        android:text="返积分31点"
                        android:layout_marginTop="10dp"
                        android:layout_marginLeft="60dp"/>
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="2dp"
                        android:background="#F4F4F4"
                        android:layout_marginTop="33dp">
                    </View>

                    <Button
                        android:id="@+id/btn01"
                        android:layout_width="150dp"
                        android:layout_height="35dp"
                        android:text="联系卖家"
                        android:layout_marginTop="35dp"
                        android:layout_marginLeft="35dp"
                        android:drawableLeft="@mipmap/wang"
                        android:background="#FFFFFF"/>
                    <Button
                        android:id="@+id/btn02"
                        android:layout_width="150dp"
                        android:layout_height="35dp"
                        android:text="拨打电话"
                        android:layout_marginTop="35dp"
                        android:layout_marginLeft="190dp"
                        android:drawableLeft="@mipmap/dianhua"
                        android:background="#FFFFFF"/>


                </RelativeLayout>
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1.7"
                    android:background="#FFFFFF">

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="5dp"
                        android:background="#F4F4F4">
                    </View>


                    <TextView
                        android:id="@+id/textddbh"
                        android:layout_width="200dp"
                        android:layout_height="20dp"
                        android:text="订单编号:2982996117180856"
                        android:layout_marginTop="3dp"
                        android:textSize="11dp"/>
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="20dp"
                        android:text="订单编号:2982996117180856"
                        android:layout_marginTop="16dp"
                        android:textSize="11dp"/>
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="20dp"
                        android:text="订单编号:2982996117180856"
                        android:layout_marginTop="28dp"
                        android:textSize="11dp"/>
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="20dp"
                        android:text="订单编号:2982996117180856"
                        android:layout_marginTop="40dp"
                        android:textSize="11dp"/>
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="20dp"
                        android:text="订单编号:2982996117180856"
                        android:layout_marginTop="51dp"
                        android:textSize="11dp"/>
                    <TextView
                        android:layout_width="200dp"
                        android:layout_height="20dp"
                        android:text="订单编号:2982996117180856"
                        android:layout_marginTop="62dp"
                        android:textSize="11dp"/>

                    <Button
                        android:id="@+id/btnfz"
                        android:layout_width="70dp"
                        android:layout_height="40dp"
                        android:text="复制"
                        android:layout_marginLeft="330dp"
                        android:layout_marginTop="5dp"/>

                </RelativeLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1.7"
                    android:background="#F4F4F4">

                <ImageView
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:src="@mipmap/aixin"
                    android:layout_marginLeft="100dp"
                    android:layout_marginTop="26dp"/>

                    <TextView
                        android:layout_width="120dp"
                        android:layout_height="30dp"
                        android:text="你可能会喜欢"
                        android:layout_marginTop="25dp"
                        android:layout_marginLeft="10dp"
                        android:textSize="20dp"/>

                </LinearLayout>
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1">

                    <View
                        android:layout_width="180dp"
                        android:layout_height="5dp"
                        android:background="#000">
                    </View>

                    <View
                        android:layout_width="180dp"
                        android:layout_height="5dp"
                        android:background="#000"
                        android:layout_marginLeft="200dp">
                    </View>

                    <Button
                        android:id="@+id/btnscdd"
                        android:layout_width="80dp"
                        android:layout_height="40dp"
                        android:text="删除订单"
                        android:layout_marginLeft="200dp"
                        android:layout_marginTop="3dp"/>

                    <Button
                        android:id="@+id/btnmlhq"
                        android:layout_width="80dp"
                        android:layout_height="40dp"
                        android:text="卖了换钱"
                        android:layout_marginLeft="290dp"
                        android:layout_marginTop="3dp"/>

                </RelativeLayout>


            </LinearLayout>

        </FrameLayout>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/activity02"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="vertical"
        android:visibility="gone"
        android:layout_weight="5">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

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

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="3"
                        android:background="#FFFFFF">

                        <ImageView
                            android:layout_width="match_parent"
                            android:layout_height="130dp"
                            android:src="@mipmap/w01"/>

                        <TextView
                            android:layout_width="120dp"
                            android:layout_height="30dp"
                            android:text="137*****676"
                            android:textSize="20dp"
                            android:textColor="#000"
                            android:layout_marginTop="120dp"
                            android:layout_marginLeft="133dp"/>

                        <TextView
                            android:layout_width="140dp"
                            android:layout_height="20dp"
                            android:text="开通词霸会员享特权"
                            android:layout_marginLeft="125dp"
                            android:layout_marginTop="140dp"/>

                    </RelativeLayout>
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2">

                        <TextView
                            android:id="@+id/ling01"
                            android:layout_width="20dp"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="50dp"
                            android:layout_marginTop="20dp"
                            android:text="0"
                            android:textSize="30dp" />

                        <TextView
                            android:id="@+id/kydf"
                            android:layout_width="100dp"
                            android:layout_height="30dp"
                            android:text="口语得分"
                            android:textSize="20dp"
                            android:layout_marginTop="60dp"
                            android:layout_marginLeft="20dp"/>

                        <TextView
                            android:id="@+id/ling02"
                            android:layout_width="20dp"
                            android:layout_height="40dp"
                            android:text="0"
                            android:textSize="30dp"
                            android:layout_marginTop="20dp"
                            android:layout_marginLeft="170dp" />

                        <TextView
                            android:id="@+id/ydps"
                            android:layout_width="100dp"
                            android:layout_height="30dp"
                            android:text="阅读篇数"
                            android:textSize="20dp"
                            android:layout_marginTop="60dp"
                            android:layout_marginLeft="140dp"/>

                        <TextView
                            android:id="@+id/ling03"
                            android:layout_width="20dp"
                            android:layout_height="40dp"
                            android:text="0"
                            android:textSize="30dp"
                            android:layout_marginTop="20dp"
                            android:layout_marginLeft="288dp" />

                        <TextView
                            android:id="@+id/tlsc"
                            android:layout_width="100dp"
                            android:layout_height="30dp"
                            android:text="听力市场"
                            android:textSize="20dp"
                            android:layout_marginTop="60dp"
                            android:layout_marginLeft="260dp"/>

                    </RelativeLayout>
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2">

                        <View
                            android:layout_width="match_parent"
                            android:layout_height="10dp"
                            android:background="#F6F6F6">
                        </View>

                        <TextView
                            android:layout_width="100dp"
                            android:layout_height="30dp"
                            android:text="学习工具"
                            android:textSize="20dp"
                            android:layout_marginLeft="10dp"
                            android:layout_marginTop="10dp"/>

                        <ImageView
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:src="@mipmap/w1"
                            android:layout_marginTop="40dp"
                            android:layout_marginLeft="30dp"/>

                        <TextView
                            android:layout_width="60dp"
                            android:layout_height="30dp"
                            android:text="生活本"
                            android:textSize="20dp"
                            android:layout_marginLeft="20dp"
                            android:layout_marginTop="80dp"/>

                        <ImageView
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:src="@mipmap/w2"
                            android:layout_marginTop="40dp"
                            android:layout_marginLeft="130dp"/>

                        <TextView
                            android:layout_width="85dp"
                            android:layout_height="30dp"
                            android:text="离线词典"
                            android:textSize="20dp"
                            android:layout_marginLeft="110dp"
                            android:layout_marginTop="80dp"/>

                        <ImageView
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:src="@mipmap/w3"
                            android:layout_marginTop="40dp"
                            android:layout_marginLeft="220dp"/>

                        <TextView
                            android:layout_width="80dp"
                            android:layout_height="30dp"
                            android:text="牛津词典"
                            android:textSize="20dp"
                            android:layout_marginLeft="202dp"
                            android:layout_marginTop="80dp"/>

                        <ImageView
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:src="@mipmap/w4"
                            android:layout_marginTop="40dp"
                            android:layout_marginLeft="310dp"/>

                        <TextView
                            android:layout_width="60dp"
                            android:layout_height="30dp"
                            android:text="柯林斯"
                            android:textSize="20dp"
                            android:layout_marginLeft="300dp"
                            android:layout_marginTop="80dp"/>

                    </RelativeLayout>
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2">

                        <View
                            android:layout_width="match_parent"
                            android:layout_height="8dp"
                            android:background="#F6F6F6">
                        </View>

                        <TextView
                            android:layout_width="100dp"
                            android:layout_height="30dp"
                            android:text="学习辅助"
                            android:textSize="20dp"
                            android:layout_marginLeft="10dp"
                            android:layout_marginTop="10dp"/>

                        <ImageView
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:src="@mipmap/w5"
                            android:layout_marginTop="40dp"
                            android:layout_marginLeft="30dp"/>

                        <TextView
                            android:layout_width="80dp"
                            android:layout_height="30dp"
                            android:text="我的课程"
                            android:textSize="20dp"
                            android:layout_marginLeft="20dp"
                            android:layout_marginTop="80dp"/>

                        <ImageView
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:src="@mipmap/w6"
                            android:layout_marginTop="40dp"
                            android:layout_marginLeft="130dp"/>

                        <TextView
                            android:layout_width="85dp"
                            android:layout_height="30dp"
                            android:text="我的书架"
                            android:textSize="20dp"
                            android:layout_marginLeft="110dp"
                            android:layout_marginTop="80dp"/>

                        <ImageView
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:src="@mipmap/w7"
                            android:layout_marginTop="40dp"
                            android:layout_marginLeft="220dp"/>

                        <TextView
                            android:layout_width="80dp"
                            android:layout_height="30dp"
                            android:text="奖学金"
                            android:textSize="20dp"
                            android:layout_marginLeft="210dp"
                            android:layout_marginTop="80dp"/>

                        <ImageView
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:src="@mipmap/w8"
                            android:layout_marginTop="40dp"
                            android:layout_marginLeft="310dp"/>

                        <TextView
                            android:layout_width="80dp"
                            android:layout_height="30dp"
                            android:text="我的会员"
                            android:textSize="20dp"
                            android:layout_marginLeft="290dp"
                            android:layout_marginTop="80dp"/>

                    </RelativeLayout>

                </LinearLayout>

            </RelativeLayout>

        </FrameLayout>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/activity03"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="5"
        android:orientation="vertical"
        android:visibility="gone">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

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

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#FFFFFF">

                        <ImageView
                            android:id="@+id/yjms"
                            android:layout_width="100dp"
                            android:layout_height="50dp"
                            android:src="@mipmap/k1"
                            android:layout_marginTop="10dp"
                            android:layout_marginLeft="8dp"/>

                        <ImageView
                            android:id="@+id/qd"
                            android:layout_width="100dp"
                            android:layout_height="50dp"
                            android:src="@mipmap/k2"
                            android:layout_marginTop="10dp"
                            android:layout_marginLeft="290dp"/>

                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="2"
                        android:background="#FFFFFF">

                        <ImageView
                            android:id="@+id/tu1"
                            android:layout_width="60dp"
                            android:layout_height="60dp"
                            android:src="@mipmap/k3"
                            android:layout_centerHorizontal="true"/>

                        <TextView
                            android:id="@+id/text01"
                            android:layout_width="180dp"
                            android:layout_height="30dp"
                            android:text="有态度网友067su3"
                            android:textSize="20dp"
                            android:textColor="#000"
                            android:layout_below="@+id/tu1"
                            android:layout_marginLeft="103dp"/>

                        <TextView
                            android:layout_width="100dp"
                            android:layout_height="30dp"
                            android:text="跟帖局科长"
                            android:layout_below="@+id/text01"
                            android:layout_marginLeft="158dp"/>

                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1.3"
                        android:background="#FFFFFF">

                        <TextView
                            android:layout_width="15dp"
                            android:layout_height="50dp"
                            android:text="1"
                            android:textSize="30dp"
                            android:layout_marginLeft="50dp"/>

                        <TextView
                            android:layout_width="50dp"
                            android:layout_height="30dp"
                            android:text="收藏"
                            android:textSize="20dp"
                            android:layout_marginLeft="40dp"
                            android:layout_marginTop="30dp"/>

                        <TextView
                            android:layout_width="80dp"
                            android:layout_height="50dp"
                            android:text="1186"
                            android:textSize="30dp"
                            android:layout_marginLeft="155dp"/>

                        <TextView
                            android:layout_width="50dp"
                            android:layout_height="30dp"
                            android:text="历史"
                            android:textSize="20dp"
                            android:layout_marginLeft="170dp"
                            android:layout_marginTop="32dp"/>

                        <TextView
                            android:layout_width="15dp"
                            android:layout_height="50dp"
                            android:text="4"
                            android:textSize="30dp"
                            android:layout_marginLeft="310dp"/>

                        <TextView
                            android:layout_width="50dp"
                            android:layout_height="30dp"
                            android:text="跟帖"
                            android:textSize="20dp"
                            android:layout_marginLeft="298dp"
                            android:layout_marginTop="30dp"/>

                    </RelativeLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="3"
                        android:orientation="vertical">

                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="0.2">

                            <View
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:background="#F6F7F9">

                            </View>

                        </RelativeLayout>
                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1"
                            android:background="#FFFFFF">

                            <ImageView
                                android:layout_width="30dp"
                                android:layout_height="30dp"
                                android:src="@mipmap/two"
                                android:layout_marginLeft="85dp"
                                android:layout_marginTop="5dp"/>

                            <TextView
                                android:layout_width="80dp"
                                android:layout_height="30dp"
                                android:text="我的消息"
                                android:layout_marginTop="7dp"
                                android:textSize="20dp"
                                android:textColor="#000"/>

                            <TextView
                                android:layout_width="120dp"
                                android:layout_height="20dp"
                                android:text="评论我的跟帖/通知"
                                android:layout_marginTop="13dp"
                                android:layout_marginLeft="220dp"/>

                        </RelativeLayout>
                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1">

                            <TextView
                                android:layout_width="80dp"
                                android:layout_height="30dp"
                                android:text="我的订阅"
                                android:layout_marginTop="7dp"
                                android:textSize="20dp"
                                android:textColor="#000"/>

                            <TextView
                                android:layout_width="180dp"
                                android:layout_height="20dp"
                                android:text="就因为一个微信头像,现在..."
                                android:layout_marginTop="13dp"
                                android:layout_marginLeft="165dp"/>

                        </RelativeLayout>
                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1">

                            <TextView
                                android:layout_width="80dp"
                                android:layout_height="30dp"
                                android:text="金币任务"
                                android:layout_marginTop="7dp"
                                android:textSize="20dp"
                                android:textColor="#000"/>

                            <TextView
                                android:layout_width="80dp"
                                android:layout_height="20dp"
                                android:text="+0/35金币"
                                android:layout_marginTop="13dp"
                                android:layout_marginLeft="270dp"/>

                        </RelativeLayout>
                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1">

                            <TextView
                                android:layout_width="80dp"
                                android:layout_height="30dp"
                                android:text="金币商城"
                                android:layout_marginTop="7dp"
                                android:textSize="20dp"
                                android:textColor="#000"/>

                            <TextView
                                android:layout_width="140dp"
                                android:layout_height="20dp"
                                android:text="珍品法国干红免费夺~"
                                android:layout_marginTop="13dp"
                                android:layout_marginLeft="200dp"/>

                        </RelativeLayout>
                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1">

                            <TextView
                                android:layout_width="80dp"
                                android:layout_height="30dp"
                                android:text="京东特权"
                                android:layout_marginTop="7dp"
                                android:textSize="20dp"
                                android:textColor="#000"/>

                            <TextView
                                android:layout_width="120dp"
                                android:layout_height="20dp"
                                android:text="新人领188元红包"
                                android:layout_marginTop="13dp"
                                android:layout_marginLeft="230dp"/>

                        </RelativeLayout>


                    </LinearLayout>

                </LinearLayout>

            </RelativeLayout>

        </FrameLayout>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/activity04"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="5"
        android:orientation="vertical"
        android:visibility="gone">

        <TextView
            android:id="@+id/dq"
            android:layout_width="match_parent"
            android:layout_height="200dp" />

        <ProgressBar
            android:id="@+id/jdt"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            style="?android:attr/progressBarStyleHorizontal"
            android:max="742" />

        <Button
            android:id="@+id/ksxz"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="开始下载"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5"
        android:background="#FFFFFF">

        <RadioGroup
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/r01"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="1"
                android:button="@null"
                android:drawableTop="@mipmap/dianhua"
                android:gravity="center"
                android:layout_weight="1" />
            <RadioButton
                android:id="@+id/r02"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="2"
                android:button="@null"
                android:drawableTop="@mipmap/dianhua"
                android:gravity="center"
                android:layout_weight="1"/>
            <RadioButton
                android:id="@+id/r03"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="3"
                android:button="@null"
                android:drawableTop="@mipmap/dianhua"
                android:gravity="center"
                android:layout_weight="1"/>
            <RadioButton
                android:id="@+id/r04"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="4"
                android:button="@null"
                android:drawableTop="@mipmap/dianhua"
                android:gravity="center"
                android:layout_weight="1"/>

        </RadioGroup>

    </LinearLayout>

</LinearLayout>


//JAVA实现代码

package com.example.tx.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class allActivity extends AppCompatActivity {

    Button btn1;
    Button btn2;
    Button btn3;
    Button btn4;
    Button btn5;

    LinearLayout linearLayout1;
    LinearLayout linearLayout2;
    LinearLayout linearLayout3;
    LinearLayout linearLayout4;

    TextView text1;

    ImageView imageView1;

    RadioButton radioButton1;
    RadioButton radioButton2;
    RadioButton radioButton3;
    RadioButton radioButton4;

    TextView textView01;
    TextView textView02;
    TextView textView03;
    TextView textView04;
    TextView textView05;
    TextView textView06;


    ImageView yejian;
    ImageView qiandao;
    ImageView touxiang;

    Button begin;
    TextView wenbenyu;
    ProgressBar jindutiao;
    StringBuffer stringBuffer = new StringBuffer();

    int sum = 0;

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

        wenbenyu = findViewById(R.id.dq);
        jindutiao = findViewById(R.id.jdt);

        linearLayout1 = findViewById(R.id.activityall);
        linearLayout2 = findViewById(R.id.activity02);
        linearLayout3 = findViewById(R.id.activity03);
        linearLayout4 = findViewById(R.id.activity04);

        text1 = findViewById(R.id.textddbh);
        imageView1 = findViewById(R.id.xiaoshi);
        imageView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                linearLayout1.setVisibility(View.INVISIBLE);
            }
        });

        btn1 = findViewById(R.id.btn01);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, "联系卖家", Toast.LENGTH_SHORT).show();
            }
        });
        btn2 = findViewById(R.id.btn02);
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, "拨打电话", Toast.LENGTH_SHORT).show();
            }
        });
        btn3 = findViewById(R.id.btnfz);
        btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, text1.getText().toString(), Toast.LENGTH_SHORT).show();
            }
        });
        btn4 = findViewById(R.id.btnscdd);
        btn4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, "删除订单", Toast.LENGTH_SHORT).show();
            }
        });
        btn5 = findViewById(R.id.btnmlhq);
        btn5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, "卖了换钱", Toast.LENGTH_SHORT).show();
            }
        });

        radioButton1 = findViewById(R.id.r01);
        radioButton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                linearLayout1.setVisibility(View.VISIBLE);
                linearLayout2.setVisibility(View.GONE);
                linearLayout3.setVisibility(View.GONE);
                linearLayout4.setVisibility(View.GONE);
            }
        });

        radioButton2 = findViewById(R.id.r02);
        radioButton2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                linearLayout1.setVisibility(View.GONE);
                linearLayout2.setVisibility(View.VISIBLE);
                linearLayout3.setVisibility(View.GONE);
                linearLayout4.setVisibility(View.GONE);
            }
        });

        radioButton3 = findViewById(R.id.r03);
        radioButton3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                linearLayout1.setVisibility(View.GONE);
                linearLayout2.setVisibility(View.GONE);
                linearLayout3.setVisibility(View.VISIBLE);
                linearLayout4.setVisibility(View.GONE);
            }
        });

        radioButton4 = findViewById(R.id.r04);
        radioButton4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                linearLayout1.setVisibility(View.GONE);
                linearLayout2.setVisibility(View.GONE);
                linearLayout3.setVisibility(View.GONE);
                linearLayout4.setVisibility(View.VISIBLE);
            }
        });

        textView01 = findViewById(R.id.ling01);
        textView02 = findViewById(R.id.ling02);
        textView03 = findViewById(R.id.ling03);

        textView04 = findViewById(R.id.kydf);
        textView04.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, "口语得分:"+textView01.getText().toString(), Toast.LENGTH_SHORT).show();
            }
        });
        textView05 = findViewById(R.id.ydps);
        textView05.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, "阅读篇数:"+textView02.getText().toString(), Toast.LENGTH_SHORT).show();
            }
        });
        textView06 = findViewById(R.id.tlsc);
        textView06.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, "听力时长:"+textView03.getText().toString(), Toast.LENGTH_SHORT).show();
            }
        });

        yejian = findViewById(R.id.yjms);
        yejian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, "夜间模式", Toast.LENGTH_SHORT).show();
            }
        });

        qiandao = findViewById(R.id.qd);
        qiandao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, "签到成功", Toast.LENGTH_SHORT).show();
            }
        });

        touxiang = findViewById(R.id.tu1);
        touxiang.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(allActivity.this, "编辑头像", Toast.LENGTH_SHORT).show();
            }
        });

        begin = findViewById(R.id.ksxz);
        begin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new LoadFile().start();
            }
        });
    }

    class LoadFile extends Thread{
        @Override
        public void run() {
            super.run();

            try {
                InputStream inputStream = getAssets().open("JiCheMeng.txt");
//                InputStreamReader inputStreamReade = new InputStreamReader(inputStream,"UTF-8");
//                BufferedReader bufferedReader = new BufferedReader(inputStreamReade);

                int maxlength = inputStream.available();
                jindutiao.setMax(maxlength);

                int len = 0;

                byte[] bytes = new byte[50];
                while((len = inputStream.read(bytes))!=-1){
                    String s = new String(bytes,0,len);
                    stringBuffer.append(s);
                    sum += len;
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    runOnUiThread(new Thread(){
                        @Override
                        public void run() {
                            super.run();
                            wenbenyu.setText(stringBuffer.toString());
                            jindutiao.setProgress(sum);
                        }
                    });

                }
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }



}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值