Android零碎小知识

news/2024/8/26 17:37:05

获取当前的版本号

 public double getVersionCode() {
    try {
        int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
        return versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return 0;
}

将版本号设置成1.0

         double version = getVersionCode();
         String result = String.format("%.1f",version);
         title.setText(String.format(getResources().getString(R.string.version_code, result)));

http://www.niftyadmin.cn/n/3649056.html

相关文章

TabActivity实现多页显示效果

由于手机屏幕有限,所以我们要尽量充分利用屏幕资源。在我们的应用程序中通常有多个Activity,而且会经常切换显示,这样我们就可以用TabActivity来显示。其效果如图1所示。 图1 tabActivity显示效果 本文就来研究TabActivity。根据帮助文档的解…

网页开端第五次培训笔记

JavaScript简介 JavaScript是一种具有面向对象能力的、解释型的程序设计语言。更具体点,它是基于对象和时间驱动并具有相对安全性的客户端脚本语言。它的主要目的是,验证发往服务器端的数据、增加Web互动、加强用户体验度等。 JavaScript的组成 ECMASc…

react中使用构建缓存_如何使用React,GraphQL和Okta构建健康跟踪应用

react中使用构建缓存介绍 (Introduction) In this tutorial, you will build a health tracking app using GraphQL API with Vesper framework, TypeORM, and MySQL as a database. These are Node frameworks, and you’ll use TypeScript for the language. For the client,…

动态添加流式布局

自定义流式布局:之前的一篇文章写过,这里就不阐述了:http://blog.csdn.net/qq_24675479/article/details/78921070 随后封装一个方法工具类:GradientDrawable代替shape,StateListDrawable替换selector设置 public class DrawUtil…

[收藏]一个广为流传的关于项目管理的通俗讲解

这是一个广为流传的关于项目管理的通俗讲解 转载出处:http://www.mypm.net/bbs/article.asp?titleid19753&ntypeid24想首先问大家一个问题:你觉得中国人聪明还是美国人聪明? 我见过最好的回答是美籍华人。 我们说美国人很愚蠢&#xff0…

android设置Activity背景色为透明的3种方法

方法一:这种方法比较简单,只有一个步骤,只需要在配置文件中把需要设置为透明的activity的样式设置为 android:theme"android:style/Theme.Translucent" 即可,这种方式只改变背景的颜色,对其他控件没有影响。…

网页开端第六次培训笔记

运算符 算数运算符赋值和扩展运算符比较运算符(""比较值与类型)逻辑运算符三目运算符 控制语句 单选择双选择多选择switch结构循环while循环do...whilefor循环死循环break与continue 数组 数组定义(隐式定义、直接实例化、定义数…

如何使用ngUpgrade从AngularJS升级到Angular

Angular (2) is here, and we’re all super excited about it. For some of us, though, we’re still maintaining large AngularJS (1.x) codebases at work. How do we start migrating our application to the new version of Angular – especially if we can’t afford …