赞
踩
目录
根据课程教学内容完成类微信的门户页面框架设计,APP最少必须包含4个tab页面。框架设计需要使用fragment,activity,不得使用UNIAPP技术进行开发(H5或者小程序)。
类微信界面要实现的功能是一个类似微信的界面,并且选择下方的不同功能可以在不同的界面之间切换。点击对应的图片之后要有相应,且响应的是对应的界面,之前生成的界面也会在下一个点击之后隐藏起来。
MainActivity.java:
- package com.example.myapplication2;
-
- 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.widget.LinearLayout;
-
- public class MainActivity extends AppCompatActivity implements View.OnClickListener {
-
- private Fragment fragment1, fragment2, fragment3, fragment4;
- private FragmentManager manager;
- private FragmentTransaction transaction;
- private LinearLayout linearLayout1, linearLayout2, linearLayout3, linearLayout4;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- linearLayout1 = findViewById(R.id.LinearLayout1);
- linearLayout2 = findViewById(R.id.LinearLayout2);
- linearLayout3 = findViewById(R.id.LinearLayout3);
- linearLayout4 = findViewById(R.id.LinearLayout4);
-
-
- fragment1 = new Fragment1();
- fragment2 = new Fragment2();
- fragment3 = new Fragment3();
- fragment4 = new Fragment4();
-
- manager = getSupportFragmentManager();
-
- initial();
-
-
-
-
- hidden();
-
- linearLayout1.setOnClickListener(this);
- linearLayout2.setOnClickListener(this);
- linearLayout3.setOnClickListener(this);
- linearLayout4.setOnClickListener(this);
-
-
-
- }
-
- private void initial() {
- transaction = manager.beginTransaction()
- .add(R.id.frameLayout, fragment1)
- .add(R.id.frameLayout, fragment2)
- .add(R.id.frameLayout, fragment3)
- .add(R.id.frameLayout, fragment4);
- transaction.commit();
- }
-
-
- @Override
- public void onClick(View view) {
- switch (vie
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。