Android开发日常

Android Studio 的 Gradle Task 没有显示的问题

Android Studio 的 Gradle Task 没有显示的问题.

隐藏软键盘

        //拿到InputMethodManager
        InputMethodManager inputMethodManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
        //如果window上view获取焦点 && view不为空
        if (inputMethodManager.isActive() && this.getCurrentFocus() != null) {
            //拿到view的token 不为空
            if (this.getCurrentFocus().getWindowToken() != null) {
                //表示软键盘窗口总是隐藏,除非开始时以SHOW_FORCED显示。
                inputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            }
        }

获取Android版本号

        /** 获取当前应用的版本号 */
        // 获取packagemanager的实例
        PackageManager packageManager = getPackageManager();
        // getPackageName()是你当前类的包名,0代表是获取版本信息
        PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(),0);
        String version = packInfo.versionName;


        /** 获取当前系统的android版本号 */
        int currentapiVersion = android.os.Build.VERSION.SDK_INT;

多屏(跳转指定屏幕)

        ActivityOptions options = ActivityOptions.makeBasic();
        options.setLaunchDisplayId(屏幕id);  // 0代表 主屏
        startActivity(new Intent(xxx), options.toBundle());

获取屏幕ID

        WindowManager windowManager = getContext().getSystemService(WindowManager.class);
        Display defaultDisplay = windowManager.getDefaultDisplay();
        int displayId = defaultDisplay.getDisplayId();

指定屏幕Toast

    public static void showToast(int displayid , String message) {
        DisplayManager displayManager = SettingApplication.getApplication().getSystemService(DisplayManager.class);
        Display display = displayManager.getDisplay(displayid);
        // 生成指定屏幕 上下文
        Context context = getApplicationContext().createDisplayContext(display);

        Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
        toast.show();
    }

Dialog 逻辑同上 生成指定 Context(上下文)即可

List 集合 Boolean 排序

Boolean 排序

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值