移动开发课程-作业1

作业内容: 完成类微信的门户页面框架设计,APP最少必须包含4个tab页面。

设计框架:fragment,activity

功能说明:展示出四个可切换界面:微信、消息、通讯录,设置

代码介绍:

布局设计:linearLayout显示顶部内容

                  底部的4个标签,使用4个LinearLayOut

                  四个Fragment 分别对应4个页面的内容:微信、朋友、通讯录、设置

页面头顶的设计:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linear_top"
    android:layout_width="match_parent"
    android:gravity="center"
    android:background="@color/blue"
    android:layout_height="55dp">
 
    <TextView
        android:id="@+id/text_top"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="我的界面"
        android:textAlignment="center"
        android:textSize="22sp" />
</LinearLayout>

制作底部界面:下面的button分成四块,每块由一个图标和一段文本构成。

<?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"
    android:id="@+id/linear_bottom"
    android:layout_width="match_parent"
    android:layout_gravity="bottom"
    android:background="@color/blue"
    android:layout_height="55dp">
 
    <LinearLayout
        android:id="@+id/wx_linear"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical">
 
        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            app:srcCompat="@drawable/p1" />
 
        <TextView
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:gravity="center"
            android:textColor="#fff"
 
            android:text="目录" />
 
    </LinearLayout>
 
    <LinearLayout
        android:id="@+id/txl_linear"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical">
 
        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
 
            app:srcCompat="@drawable/p2" />
 
        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:gravity="center"
            android:text="消息"
            android:textColor="#fff" />
 
    </LinearLayout>
 
    <LinearLayout
        android:id="@+id/fx_linear"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical">
 
        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            app:srcCompat="@drawable/p3" />
 
        <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:gravity="center"
            android:textColor="#fff"
            android:text="设置" />
 
    </LinearLayout>
 
    <LinearLayout
        android:id="@+id/w_linear"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical">
 
        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            app:srcCompat="@drawable/p4" />
 
        <TextView
            android:id="@+id/textView4"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:gravity="center"
            android:textColor="#fff"
            android:text="微信" />
 
    </LinearLayout>
</LinearLayout>

制作主页面

<?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=".MainActivity" >
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
 
        <include
            layout="@layout/top"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
 
        <FrameLayout
            android:id="@+id/id_content"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">
 
        </FrameLayout>
 
        <include
            layout="@layout/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
 
    </LinearLayout>
 
 
</LinearLayout>

在与MainActivity.java相同的目录下新建四个Fragment,每个代表不同图标的界面

private Fragment mTab01 = new weixinFragment();
    private Fragment mTab02 = new frdFragment();
    private Fragment mTab03 = new contactFragment();
    private Fragment mTab04 = new settingFragment();

    private FragmentManager fm;
    private void initFragment() {
        fm = getSupportFragmentManager();
        FragmentTransaction transaction = fm.beginTransaction();
        transaction.add(R.id.id_content,mTab01);
        transaction.add(R.id.id_content,mTab02);
        transaction.add(R.id.id_content,mTab03);
        transaction.add(R.id.id_content,mTab04);
        transaction.commit();
    }

initView()函数,其中上面四个参数用来存储四个bottom图片底下的文字,下面四个参数用来存储四个图片

    private void initView(){
        mTabWeixin = (LinearLayout)findViewById(R.id.id_tab_weixin);
        mTabFrd = (LinearLayout)findViewById(R.id.id_tab_frd);
        mTabAddress = (LinearLayout)findViewById(R.id.id_tab_contact);
        mTabSettings = (LinearLayout)findViewById(R.id.id_tab_settings);

        mImgWeixin = (ImageButton)findViewById(R.id.id_tab_weixin_img);
        mImgFrd = (ImageButton)findViewById(R.id.id_tab_frd_img);
        mImgAddress = (ImageButton)findViewById(R.id.id_tab_contact_img);
        mImgSettings = (ImageButton)findViewById(R.id.id_tab_settings_img);
    }

对4个按钮进行监听

    @Override
    public void onClick(View v) {

        resetimg();

        switch (v.getId()){
            case id.id_tab_weixin_img:
                setSelect(0);
                break;
            case id.id_tab_frd_img:
                setSelect(1);
                break;
            case id.id_tab_contact_img:
                setSelect(2);
                break;
            case id.id_tab_settings_img:
                setSelect(3);
                break;
            default:
                break;
        }
    }

mainactivitiy.java文件

package com.example.homework1_xc;
 
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
 
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
 
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private LinearLayout linearWx,linearMF,linearBM,linearS;
    private ImageView imgWx,imgTxl,imgBM,imgW,imgCur;
    private TextView textWx,textTxl,textFx,textW,textCur;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
 
        initFun();
        addFragment(new SetFlagment());
        imgWx.setSelected(true);
        textWx.setSelected(true);
    }
    private void initFun(){
        linearWx = findViewById(R.id.wx_linear);
        linearWx.setOnClickListener(this);
        linearMF = findViewById(R.id.txl_linear);
        linearMF.setOnClickListener(this);
        linearBM = findViewById(R.id.fx_linear);
        linearBM.setOnClickListener(this);
        linearS = findViewById(R.id.w_linear);
        linearS.setOnClickListener(this);
 
        imgWx = findViewById(R.id.imageView);
        imgTxl = findViewById(R.id.imageView2);
        imgBM = findViewById(R.id.imageView3);
        imgW = findViewById(R.id.imageView4);
        imgCur = findViewById(R.id.imageView);
 
        textWx = findViewById(R.id.textView);
        textTxl = findViewById(R.id.textView2);
        textFx = findViewById(R.id.textView3);
        textW = findViewById(R.id.textView4);
        textCur = findViewById(R.id.textView);
    }
 
 
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.wx_linear:
                changeFragment(new BookmarkFragment());
                colorChange(1);
                break;
            case R.id.txl_linear:
                changeFragment(new MessageFlagment());
                colorChange(2);
                break;
            case R.id.fx_linear:
                changeFragment(new WechatFlagment());
                colorChange(3);
                break;
            case R.id.w_linear:
                changeFragment(new SetFlagment());
                colorChange(4);
                break;
            default:
                break;
        }
 
    }
 
    private void colorChange(int id){
        textCur.setSelected(false);
        imgCur.setSelected(false);
        switch (id){
            case 1:
                imgWx.setSelected(true);
                imgCur=imgWx;
                textWx.setSelected(true);
                textCur=textWx;
                break;
            case 2:
                imgTxl.setSelected(true);
                imgCur=imgTxl;
                textTxl.setSelected(true);
                textCur=textTxl;
                break;
            case 3:
                imgBM.setSelected(true);
                imgCur=imgBM;
                textFx.setSelected(true);
                textCur=textFx;
                break;
            case 4:
                imgW.setSelected(true);
                imgCur=imgW;
                textW.setSelected(true);
                textCur=textW;
                break;
            default:
                break;
 
        }
    }
 
    private void changeFragment(Fragment fragment){
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.body, fragment);
        transaction.commit();
    }
 
    private void addFragment(Fragment fragment){
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.add(R.id.body, fragment);
        transaction.commit();
    }
}

运行截图

 

 

 geek地址:我的工作台 - Gitee.com

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: MIT移动开发技术大作业是指麻省理工学院移动开发技术课程的大作业。该课程旨在教授学生移动应用开发的基本知识和技巧,使他们能够开发出功能完善、用户友好的移动应用程序。 在大作业中,学生需要通过结合课程所学的理论知识和实践技能,选择一个具有挑战性的移动应用项目来完成。他们需要分析目标用户群体的需求,设计应用界面,实现核心功能,进行用户测试和反馈收集,并最终提交一个完整的移动应用项目。 大作业的评估标准主要包括功能完整性、用户友好性、创新性以及代码质量等方面。学生需要展示他们在移动应用开发过程中的技术能力和创造力,并能够有效地解决实际问题。 通过这个大作业,学生将能够巩固和应用所学的理论知识,提升移动应用开发的实践能力。此外,学生还能够通过与目标用户的交互和反馈收集,理解用户需求,改善和优化应用程序。 总之,MIT移动开发技术大作业是培养学生移动应用开发技能和创新能力的重要环节,通过该作业的完成,学生能够应对实际挑战,开发出符合用户需求的高质量移动应用程序。 ### 回答2: MIT移动开发技术大作业是一项针对学生而设计的任务,旨在提升学生在移动开发方面的技术能力和创新能力。在这个大作业中,学生通常被要求完成一个移动应用的开发,该应用可以是一个游戏、社交媒体应用、健康管理工具等。 完成MIT移动开发技术大作业需要学生具备一定的编程基础和移动开发相关知识。学生需要利用所学的编程语言开发工具,例如Java、Swift、React Native等,来设计和开发一个功能完整且具有创新性的移动应用。在开发的过程中,学生需要理解移动应用的设计原则和用户体验,同时考虑应用的性能优化和安全性等方面。 大作业的评估标准通常包括应用的功能实现程度、界面设计与交互体验、代码结构与质量、创新性和实用性等。学生需要通过清晰的需求分析、合理的系统设计和高质量的编码来完成任务,并能进行有效的测试和调试。 这个大作业为学生提供了一个实践和展示自己技术能力的机会,同时也鼓励学生探索和创新。通过完成这个大作业,学生可以深入理解移动开发的流程和技术要点,提升自己的综合能力,并为以后的学习和就业打下坚实的基础。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值