教育システムAPP(C)

チャレンジミッションは、
教育システムAPP(2)だけでなく、教育システムAPP(c)を見直します

検査のログインおよび登録モジュール。
メインインターフェイスで表示したHello Worldの位置、メイン画面に戻り、MainActivityとLoginActivityは、メインインターフェイスになっウェルカム画面の後、自動的にログイン画面にジャンプし、ログインが成功すると、変更してください:「成功に記号」ユーザー名+

ソリューション

タスクを解決する
何のAndroidManifest.xmlを見るために

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="cn.edu.gdmec.android.boxuegu">

    <!--原为android:theme="@style/AppTheme"-->
    <!--去除ActionBar标题栏-->
    <!--添加应用图标,app_icon-->
    <application
        android:allowBackup="true"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.NoActionBar">
        <activity android:name=".activity.SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!--添加实现类-->
        <activity android:name=".activity.MainActivity"></activity>
        <activity android:name=".activity.LoginActivity"></activity>
        <activity android:name=".activity.RegisterActivity"></activity>
    </application>
</manifest>

その後activity_main.xml表示に追加し、中MainActivityでの書き込みコードは、表示helloWordアカウントを変更します。

<?xml version="1.0" encoding="utf-8"?>
<!--任务:检验登录和注册模块-->
<!--在主界面的Hello World位置显示:用户名+“登录成功”-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center">

    <TextView
        android:id="@+id/et_user_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="hello"
        android:layout_gravity="center"/>

</LinearLayout>
package cn.edu.gdmec.android.boxuegu.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import cn.edu.gdmec.android.boxuegu.R;
/*任务在主界面的Hello World位置显示:用户名+“登录成功”*/
public class MainActivity extends AppCompatActivity {
    private TextView et_user_name;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        et_user_name = findViewById(R.id.et_user_name);
        Intent intent=new Intent(MainActivity.this,LoginActivity.class);
        startActivityForResult(intent,1);
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data!=null){
            String userName = data.getStringExtra("userName");
            //if (!TextUtils.isEmpty(userName)){
            Toast.makeText(MainActivity.this,"登陆成功:"+userName, Toast.LENGTH_SHORT).show();
            et_user_name.setText(userName);
            //}
        }
    }
}

最後にLoginActivityの下で:

data.putExtra("userName",userName);

教育システムAPPメインインターフェイスの(c)の
目標を学習:登録とログインモジュールの開発をマスターするには、モジュールは機能を切り替えることができます。

タスクに挑戦し、メインページ、

学習の目標
メインインターフェースは三つのモジュール、すなわち、カリキュラムモジュール、エクササイズモジュール、ユーザー・モジュールを有しています。三つのモジュールをジャンプする下部のナビゲーションバー上のユーザーがクリックを達成することができます。
主なインタフェースは、3つのスイッチングモジュールを作るために使用されます。断片は、3つのインターフェイスモジュールの担体として用います。

実装タスク
画像リソースの配置
この実験で使用した画像リソースは、それぞれ、6ある
main_exercises_icon.png、
main_course_icon.png、
main_my_icon.png
main_exercises_icon_selected.png、
main_course_icon_selected.png、
main_my_icon_selected.png
画像リソースを使用するように配置しますフォルダにdrawrable。

ファイル

activity_mainレイアウト
MainActivityページには次の2つの領域で構成されています
のmain_bodyプットフラグメント
下部のナビゲーションバーmain_bottom_bar
activity_main.xmlの完全なコードを

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <LinearLayout
        android:orientation="vertical"
        android:background="@android:color/white"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <!--标题栏-->
        <include layout="@layout/main_title_bar"/>
        <!--放置Fragment的main_body-->
        <RelativeLayout
            android:id="@+id/main_body"
            android:background="@android:color/white"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </RelativeLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/main_bottom_bar"
        android:layout_alignParentBottom="true"
        android:background="#F2F2F2"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="55dp">
        <RelativeLayout
            android:layout_weight="1"
            android:id="@+id/bottom_bar_course_btn"
            android:layout_width="0dp"
            android:layout_height="match_parent">
            <TextView
                android:id="@+id/bottom_bar_text_course"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="3dp"
                android:gravity="center"
                android:singleLine="true"
                android:text="课 程"
                android:textColor="#666666"
                android:textSize="14sp"/>
            <ImageView
                android:layout_width="27dp"
                android:layout_height="27dp"
                android:layout_above="@+id/bottom_bar_text_course"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="3dp"
                android:id="@+id/bottom_bar_image_course"
                android:src="@drawable/main_course_icon"/>
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/bottom_bar_exercises_btn"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent">
            <TextView
                android:id="@+id/bottom_bar_text_exercises"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="3dp"
                android:gravity="center"
                android:singleLine="true"
                android:text="习 题"
                android:textColor="#666666"
                android:textSize="14sp"/>
            <ImageView
                android:layout_width="27dp"
                android:layout_height="27dp"
                android:layout_above="@+id/bottom_bar_text_exercises"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="3dp"
                android:id="@+id/bottom_bar_image_exercises"
                android:src="@drawable/main_exercises_icon"/>
        </RelativeLayout>
        <RelativeLayout
            android:layout_weight="1"
            android:id="@+id/bottom_bar_myinfo_btn"
            android:layout_width="0dp"
            android:layout_height="match_parent">
            <TextView
                android:id="@+id/bottom_bar_text_myinfo"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="3dp"
                android:gravity="center"
                android:singleLine="true"
                android:text="我"
                android:textColor="#666666"
                android:textSize="14sp"/>
            <ImageView
                android:layout_width="27dp"
                android:layout_height="27dp"
                android:layout_above="@+id/bottom_bar_text_myinfo"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="3dp"
                android:id="@+id/bottom_bar_image_myinfo"
                android:src="@drawable/main_my_icon"/>
        </RelativeLayout>
    </LinearLayout>
</RelativeLayout>

制御インスタンス
タップMainActivityを

public class MainActivity extends AppCompatActivity {
    private RelativeLayout main_body;
    private TextView bottom_bar_text_course;
    private ImageView bottom_bar_image_course;
    private RelativeLayout bottom_bar_course_btn;
    private TextView bottom_bar_text_exercises;
    private ImageView bottom_bar_image_exercises;
    private RelativeLayout bottom_bar_exercises_btn;
    private TextView bottom_bar_text_myinfo;
    private ImageView bottom_bar_image_myinfo;
    private RelativeLayout bottom_bar_myinfo_btn;
    private LinearLayout main_bottom_bar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }


    private void initView() {
        main_body = findViewById(R.id.main_body);
        bottom_bar_text_course = findViewById(R.id.bottom_bar_text_course);
        bottom_bar_image_course = findViewById(R.id.bottom_bar_image_course);
        bottom_bar_course_btn = findViewById(R.id.bottom_bar_course_btn);
        bottom_bar_text_exercises = findViewById(R.id.bottom_bar_text_exercises);
        bottom_bar_image_exercises = findViewById(R.id.bottom_bar_image_exercises);
        bottom_bar_exercises_btn = findViewById(R.id.bottom_bar_exercises_btn);
        bottom_bar_text_myinfo = findViewById(R.id.bottom_bar_text_myinfo);
        bottom_bar_image_myinfo = findViewById(R.id.bottom_bar_image_myinfo);
        bottom_bar_myinfo_btn = findViewById(R.id.bottom_bar_myinfo_btn);
        main_bottom_bar = findViewById(R.id.main_bottom_bar);
    }

}

それを完了するために、一部のインスタンスを制御します。

下部のナビゲーションバーの状態の切り替え方法
スイッチをクリックしながら、下部のナビゲーションバーには、変色の影響があるでしょう。

ファイル

setSelectStatus()メソッドを追加するMainActivity。

    private void setSelectStatus(int index) {
        switch (index){
            case 0:
                bottom_bar_image_course.setImageResource(R.drawable.main_course_icon_selected);
                bottom_bar_text_course.setTextColor(Color.parseColor("#0097F7"));
                bottom_bar_text_exercises.setTextColor(Color.parseColor("#666666"));
                bottom_bar_text_myinfo.setTextColor(Color.parseColor("#666666"));
                bottom_bar_image_exercises.setImageResource(R.drawable.main_exercises_icon);
                bottom_bar_image_myinfo.setImageResource(R.drawable.main_my_icon);
                break;
            case 1:
                bottom_bar_image_exercises.setImageResource(R.drawable.main_exercises_icon_selected);
                bottom_bar_text_exercises.setTextColor(Color.parseColor("#0097F7"));
                bottom_bar_text_course.setTextColor(Color.parseColor("#666666"));
                bottom_bar_text_myinfo.setTextColor(Color.parseColor("#666666"));
                bottom_bar_image_course.setImageResource(R.drawable.main_course_icon);
                bottom_bar_image_myinfo.setImageResource(R.drawable.main_my_icon);
                break;
            case 2:
                bottom_bar_image_myinfo.setImageResource(R.drawable.main_my_icon_selected);
                bottom_bar_text_myinfo.setTextColor(Color.parseColor("#0097F7"));
                bottom_bar_text_course.setTextColor(Color.parseColor("#666666"));
                bottom_bar_text_exercises.setTextColor(Color.parseColor("#666666"));
                bottom_bar_image_exercises.setImageResource(R.drawable.main_exercises_icon);
                bottom_bar_image_course.setImageResource(R.drawable.main_course_icon);
                break;
        }
    }

現在選択されているボタンを決定する指標パラメータのsetSelectStatus()メソッド。

ナビゲーションの応答底
書かれたナビゲーションバーの色遷移の方法は、応答方法をクリックして行きました。
与えるMainActivityプラスView.OnClickListenerインタフェース

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

ALT +は、ののonClick()メソッドを生成します
添加のonClick()メソッドを生成したナビゲーション領域で応答を。

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bottom_bar_course_btn:
                setSelectStatus(0);
                break;
            case R.id.bottom_bar_exercises_btn:
                setSelectStatus(1);
                break;
            case R.id.bottom_bar_myinfo_btn:
                setSelectStatus(2);
                break;
        }
    }

3つのRelativeLayoutコントロールのリスナーを追加することを忘れないでください、
私の習慣はinitView()メソッドリガです。

        bottom_bar_course_btn.setOnClickListener(this);
        bottom_bar_exercises_btn.setOnClickListener(this);
        bottom_bar_myinfo_btn.setOnClickListener(this);

この時点で、コードの下のナビゲーションバーは完了です。

    private void initView() {
        main_body = findViewById(R.id.main_body);
        bottom_bar_text_course = findViewById(R.id.bottom_bar_text_course);
        bottom_bar_image_course = findViewById(R.id.bottom_bar_image_course);
        bottom_bar_course_btn = findViewById(R.id.bottom_bar_course_btn);
        bottom_bar_text_exercises = findViewById(R.id.bottom_bar_text_exercises);
        bottom_bar_image_exercises = findViewById(R.id.bottom_bar_image_exercises);
        bottom_bar_exercises_btn = findViewById(R.id.bottom_bar_exercises_btn);
        bottom_bar_text_myinfo = findViewById(R.id.bottom_bar_text_myinfo);
        bottom_bar_image_myinfo = findViewById(R.id.bottom_bar_image_myinfo);
        bottom_bar_myinfo_btn = findViewById(R.id.bottom_bar_myinfo_btn);
        main_bottom_bar = findViewById(R.id.main_bottom_bar);

        bottom_bar_course_btn.setOnClickListener(this);
        bottom_bar_exercises_btn.setOnClickListener(this);
        bottom_bar_myinfo_btn.setOnClickListener(this);
    }

3つのフラグメントを作成し
、私たちはまだ断片三つのモジュールのメソッドを使用し、それを行うためにインターフェイス。
まず、新しい3つのレイアウトファイル。
fragment_course.xml
fragment_exercises.xml
fragment_myinfo.xml
コンテンツレイアウトファイルはFragment_1 / 2/3を読んで大きなTextViewのに似ています。背景色やフォントの色を変更することを忘れないでください。

fragment_course.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Fragment_1"
        android:textColor="@android:color/black"
        android:textSize="50sp"/>
</LinearLayout>
fragment_exercises.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Fragment_2"
        android:textColor="@android:color/black"
        android:textSize="50sp"/>
</LinearLayout>

fragment_myinfo.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Fragment_3"
        android:textColor="@android:color/black"
        android:textSize="50sp"/>
</LinearLayout>

それらへのフラグメントのビルドパッケージ、3断片
CourseFragment.java

package cn.edu.gdmec.android.boxuegu.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import cn.edu.gdmec.android.boxuegu.R;

public class CourseFragment extends Fragment {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_course, null);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

    }
}

ExercisesFragment.java

package cn.edu.gdmec.android.boxuegu.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import cn.edu.gdmec.android.boxuegu.R;

public class ExercisesFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_exercises, null);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

    }

}

MyinfoFragment.java

package cn.edu.gdmec.android.boxuegu.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import cn.edu.gdmec.android.boxuegu.R;

public class MyinfoFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_myinfo, null);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

    }

}

三つのフラグメントの表示とスイッチが
android.support.v4.app.Fragment使用フラグメント
我々はAppCompatActivityはMainActivity年にFragmentActivityを変え入れ、次へを。

public class MainActivity extends FragmentActivity implements View.OnClickListener{

断片は、以下の活性のコードに追加しました

FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.add(R.id.main_body,new CourseFragment()).commit();

私たちは、最初のページを開くために使用setMain()メソッドを、書きました

    private void setMain() {
        this.getSupportFragmentManager().beginTransaction().add(R.id.main_body,new CourseFragment()).commit();
        setSelectStatus(0);
    }

合字の使用が断片アクティビティコード上記と同じ効果に追加されると、ありますが、これは個人的な習慣に依存します。

コールのonCreate()メソッドで

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setMain();
    }

あなたは私たちが中のonClick()メソッドを追加スイッチングフラグメント応答方法のフラグメントを切り替えるために下のナビゲーションバーをクリックすると。

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bottom_bar_course_btn:
                getSupportFragmentManager().beginTransaction().add(R.id.main_body,new CourseFragment()).commit();
                setSelectStatus(0);
                break;
            case R.id.bottom_bar_exercises_btn:
                getSupportFragmentManager().beginTransaction().add(R.id.main_body,new ExercisesFragment()).commit();
                setSelectStatus(1);
                break;
            case R.id.bottom_bar_myinfo_btn:
                getSupportFragmentManager().beginTransaction().add(R.id.main_body,new MyinfoFragment()).commit();
                setSelectStatus(2);
                break;
        }
    }

完全MainActivity.java

package cn.edu.gdmec.android.boxuegu.activity;

import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import cn.edu.gdmec.android.boxuegu.R;
import cn.edu.gdmec.android.boxuegu.fragment.CourseFragment;
import cn.edu.gdmec.android.boxuegu.fragment.ExercisesFragment;
import cn.edu.gdmec.android.boxuegu.fragment.MyinfoFragment;

/*任务在主界面的Hello World位置显示:用户名+“登录成功”*/
public class MainActivity extends FragmentActivity implements View.OnClickListener{
    private RelativeLayout main_body;
    private TextView bottom_bar_text_course;
    private ImageView bottom_bar_image_course;
    private RelativeLayout bottom_bar_course_btn;
    private TextView bottom_bar_text_exercises;
    private ImageView bottom_bar_image_exercises;
    private RelativeLayout bottom_bar_exercises_btn;
    private TextView bottom_bar_text_myinfo;
    private ImageView bottom_bar_image_myinfo;
    private RelativeLayout bottom_bar_myinfo_btn;
    private LinearLayout main_bottom_bar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        //把Fragment加到Activity里的代码如下
       /* FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.add(R.id.main_body,new CourseFragment()).commit();*/
       setMain();
    }

    private void setMain() {
        this.getSupportFragmentManager().beginTransaction().add(R.id.main_body,new MyinfoFragment()).commit();
        setSelectStatus(2);
    }

    private void setSelectStatus(int index) {
        switch (index){
            case 0:
                bottom_bar_image_course.setImageResource(R.drawable.main_course_icon_selected);
                bottom_bar_text_course.setTextColor(Color.parseColor("#0097F7"));
                bottom_bar_text_exercises.setTextColor(Color.parseColor("#666666"));
                bottom_bar_text_myinfo.setTextColor(Color.parseColor("#666666"));
                bottom_bar_image_exercises.setImageResource(R.drawable.main_exercises_icon);
                bottom_bar_image_myinfo.setImageResource(R.drawable.main_my_icon);
                break;
            case 1:
                bottom_bar_image_exercises.setImageResource(R.drawable.main_exercises_icon_selected);
                bottom_bar_text_exercises.setTextColor(Color.parseColor("#0097F7"));
                bottom_bar_text_course.setTextColor(Color.parseColor("#666666"));
                bottom_bar_text_myinfo.setTextColor(Color.parseColor("#666666"));
                bottom_bar_image_course.setImageResource(R.drawable.main_course_icon);
                bottom_bar_image_myinfo.setImageResource(R.drawable.main_my_icon);
                break;
            case 2:
                bottom_bar_image_myinfo.setImageResource(R.drawable.main_my_icon_selected);
                bottom_bar_text_myinfo.setTextColor(Color.parseColor("#0097F7"));
                bottom_bar_text_course.setTextColor(Color.parseColor("#666666"));
                bottom_bar_text_exercises.setTextColor(Color.parseColor("#666666"));
                bottom_bar_image_exercises.setImageResource(R.drawable.main_exercises_icon);
                bottom_bar_image_course.setImageResource(R.drawable.main_course_icon);
                break;
        }
    }
    private void initView() {
        main_body = findViewById(R.id.main_body);
        bottom_bar_text_course = findViewById(R.id.bottom_bar_text_course);
        bottom_bar_image_course = findViewById(R.id.bottom_bar_image_course);
        bottom_bar_course_btn = findViewById(R.id.bottom_bar_course_btn);
        bottom_bar_text_exercises = findViewById(R.id.bottom_bar_text_exercises);
        bottom_bar_image_exercises = findViewById(R.id.bottom_bar_image_exercises);
        bottom_bar_exercises_btn = findViewById(R.id.bottom_bar_exercises_btn);
        bottom_bar_text_myinfo = findViewById(R.id.bottom_bar_text_myinfo);
        bottom_bar_image_myinfo = findViewById(R.id.bottom_bar_image_myinfo);
        bottom_bar_myinfo_btn = findViewById(R.id.bottom_bar_myinfo_btn);
        main_bottom_bar = findViewById(R.id.main_bottom_bar);

        bottom_bar_course_btn.setOnClickListener(this);
        bottom_bar_exercises_btn.setOnClickListener(this);
        bottom_bar_myinfo_btn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bottom_bar_course_btn:
                getSupportFragmentManager().beginTransaction().add(R.id.main_body,new CourseFragment()).commit();
                setSelectStatus(0);
                break;
            case R.id.bottom_bar_exercises_btn:
                getSupportFragmentManager().beginTransaction().add(R.id.main_body,new ExercisesFragment()).commit();
                setSelectStatus(1);
                break;
            case R.id.bottom_bar_myinfo_btn:
                getSupportFragmentManager().beginTransaction().add(R.id.main_body,new MyinfoFragment()).commit();
                setSelectStatus(2);
                break;
        }
    }
}

まあ、完成されたが、新たに追加されたカテゴリのアクティビティがありません。次の挑戦タスク!

タスクに挑戦し
たページを開くには、初めてはFragment_1は、最初のオープニングページがFragment_3になるようにコードを変更してください、また、オハイオ州の下部にあるナビゲーションバーの色を変更することを忘れないでくださいされています

要約
これは良い三段階のAndroidを取ることです!

❤️DOは学習あなたの足跡を残すことを忘れないで[コメント+ +のように収集ポイント]

情報を著者:

[著者]:Jeskson
[オリジナル]公開番号:ダダフロントエンドビストロ。
[福祉]:自己学習教材をまくるに送信されませ公共返信「情報」(シェアへのグループには何がハを言いたい、私は見ませんでした)!
[予約]説明:ソースを明記してください、ありがとう再現!

大規模なテクノロジ・スタックのブログを配置するフロントエンド開発、フロントエンドの開発、PHPの背景知識、ウェブフルスタック技術分野、データ構造とアルゴリズム、およびそう簡単にネットワーク理論を理解するためには、ジュニアパートナーに提示されます。、あなたがサポートして愛の礼儀をありがとうございました!


ローカルコンテンツのこの数はビットを取得しない場合(例:著作権やその他の問題に)、タイムリーにすることができ整流のための私達に連絡し、最初の時間に処理されますしてください。


親指アップしてください!あなたが同意しているので/励ましは、私の文章の最大の力です!

ようこそ注意ダダさんCSDN!

これは、品質、態度のブログです

フロントエンド技術スタック

おすすめ

転載: www.cnblogs.com/dashucoding/p/12160882.html