Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssss #20

Closed
appdev opened this issue Apr 13, 2020 · 0 comments
Closed

ssss #20

appdev opened this issue Apr 13, 2020 · 0 comments

Comments

@appdev
Copy link
Owner

appdev commented Apr 13, 2020

package com.android.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.fragment.MenuFragment;
//import com.special.ResideMenu.ResideMenu;
//import com.special.ResideMenu.ResideMenuInfo;
//import com.special.ResideMenu.ResideMenuItem;

public class MainActivity extends FragmentActivity {

    public Fragment mContent;
    public TextView maintitle;
    public ImageView logo;

    private MenuFragment fragment;

    MyApplication myApp;

    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        maintitle = (TextView) findViewById(R.id.main_txt);
        logo = (ImageView) findViewById(R.id.logo);

        myApp = (MyApplication) getApplication();

        // changeFragment(new HuDongFragment());
        initView();// 初始化页面信息
    }


    // 监听手机上的BACK键
    //public boolean onKeyDown(int keyCode, KeyEvent event) {
    //    if (keyCode == KeyEvent.KEYCODE_BACK) {
    //        // 判断菜单是否关闭
    //        if (is_closed) {
    //            // 判断两次点击的时间间隔(默认设置为2秒)ime) > 2000) {
    //                Toast.makeText(this, "再按一次退出程
    //            if ((System.currentTimeMillis() - mExitT序", Toast.LENGTH_SHORT).show();

    //                mExitTime = System.currentTimeMillis();
    //            } else {
    //                finish();
    //                System.exit(0);
    //                super.onBackPressed();
    //            }
    //        } else {
    //            resideMenu.closeMenu();
    //        }
    //        return true;
    //    }
    //    return super.onKeyDown(keyCode, event);
    //}

    private void initView() {

        maintitle.setText("今日签到");
        fragment =  new MenuFragment();
        mContent = fragment;

        // 显示主页面
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.content_frame, mContent).commit();

    }

    public void switchContent(Fragment fragment) {
        fragment.getClass().getSimpleName() == fragment.getClass().getSimpleName()

        mContent = fragment;

        getSupportFragmentManager().beginTransaction()
                .replace(R.id.content_frame, fragment).commit();

    }

    @Override
    public void onBackPressed() {
        switchContent(fragment);
        //  super.onBackPressed();
    }
}

@appdev appdev closed this as completed Jul 8, 2020
@appdev appdev reopened this Jul 8, 2020
@appdev appdev closed this as completed Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant