android中细节效果总结
andorid取消最上方的标题同时全屏显示
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //取消最上方的标题栏 requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.splash); //全屏显示 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }整个app取消标题
android:theme=”@android:style/Theme.Translucent.NoTitleBar”
获取版本号
- private String getVersion() {
- try {
- // getPackageName()得到当前应用包名,当前应用的版本号通过包管理器得到
- PackageInfo info = getPackageManager().getPackageInfo(
- getPackageName(), 0);
- return info.versionName;
- } catch (Exception e) {
- e.printStackTrace();
- return "没得到";
- }
- }
淡入淡出动画效果
- rl_splash_animation = (RelativeLayout) findViewById(R.id.rl_splash_animation);
- //从完全透明到完全不透明动画效果
- AlphaAnimation a = new AlphaAnimation(0.0f, 1.0f);
- a.setDuration(2000);//动画时间两秒钟
- rl_splash_animation.setAnimation(a);
弹出对话框,下面的代码,是一个升级提醒,仅供参考。
- /**
- * 升级的对话框
- */
- private void showUpdataDialog() {
- AlertDialog.Builder buider = new Builder(this);
- buider.setIcon(R.drawable.icon5);
- buider.setTitle("升级提醒");
- buider.setMessage(info.getDescription());
- buider.setCancelable(false); // 让用户不能取消对话框
- buider.setPositiveButton("确定", new OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- Log.i(TAG, "下载apk文件" + info.getApkurl());
- if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
- DownLoadFileThreadTask task = new DownLoadFileThreadTask(info.getApkurl(), "/sdcard/new.apk");
- pd.show();
- new Thread(task).start();
- }else{
- Toast.makeText(getApplicationContext(), "sd卡不可用", 1).show();
- loadMainUI();
- }
- }
- });
- buider.setNegativeButton("取消", new OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- Log.i(TAG, "用户取消进入程序主界面");
- loadMainUI();
- }
- });
- buider.create().show();
- }
从服务器是获取xml文件,然后解析的一个业务方法
首先传入id这个id是在values里边的一个xml配置文件的id里边是服务器xml文件的地址
然后通过
HttpURLConnection连接服务器,InputStream is = conn.getInputStream();发送请求得到输入流
- /**
- *
- * @param urlid 服务器路径string对应的id
- * @return 更新的信息
- */
- public UpdataInfo getUpdataInfo(int urlid) throws Exception{
- String path = context.getResources().getString(urlid);
- URL url = new URL(path);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setConnectTimeout(2000);
- conn.setRequestMethod("GET");
- InputStream is = conn.getInputStream();
- return UpdataInfoParser.getUpdataInfo(is);
- }
解析的xml的inputstream,传入xml文件的
inputstream流,读取里边的文件
- /**
- *
- * @param is
- * 解析的xml的inputstream
- * @return updateinfo
- */
- public static UpdataInfo getUpdataInfo(InputStream is) throws Exception {
- XmlPullParser parser = Xml.newPullParser();
- UpdataInfo info = new UpdataInfo();
- parser.setInput(is, "utf-8");
- int type = parser.getEventType();//定位到文档的开始
- while (type != XmlPullParser.END_DOCUMENT) {//不到末尾
- switch (type) {
- case XmlPullParser.START_TAG:
- if("version".equals(parser.getName())){
- String version = parser.nextText();
- info.setVersion(version);
- }else if("description".equals(parser.getName())){
- String description = parser.nextText();
- info.setDescription(description);
- }else if("apkurl".equals(parser.getName())){
- String apkurl = parser.nextText();
- info.setApkurl(apkurl);
- }
- break;
- }
- type = parser.next();//向下
- }
- return info;
- }
Intent如何传值
- 案例一
- 传值:
- Intent intent=new Intent();
- intent.putExtra("extra", "这是页面一传来的值!");
- intent.setClass(Test_for_intentActivity.this, actpage2.class);
- startActivity(intent);
- 取值:
- Intent intent=getIntent();
- String StringE=intent.getStringExtra("extra");
- TextView text2=(TextView)findViewById(R.id.textView2);
- text2.setText(StringE);
- 打开网页
- Uri uri = Uri.parse("http://www.google.com");
- Intent it = new Intent(Intent.ACTION_VIEW,uri);
- startActivity(it);
android中细节效果总结的更多相关文章
- Android中的LinearLayout布局
LinearLayout : 线性布局 在一般情况下,当有很多控件需要在一个界面列出来时,我们就可以使用线性布局(LinearLayout)了, 线性布局是按照垂直方向(vertical)或水平方向 ...
- Android中BroadcastReceiver的两种注册方式(静态和动态)详解
今天我们一起来探讨下安卓中BroadcastReceiver组件以及详细分析下它的两种注册方式. BroadcastReceiver也就是"广播接收者"的意思,顾名思义,它就是用来 ...
- Android中使用ExpandableListView实现微信通讯录界面(完善仿微信APP)
之前的博文<Android中使用ExpandableListView实现好友分组>我简单介绍了使用ExpandableListView实现简单的好友分组功能,今天我们针对之前的所做的仿微信 ...
- Android中ListView实现图文并列并且自定义分割线(完善仿微信APP)
昨天的(今天凌晨)的博文<Android中Fragment和ViewPager那点事儿>中,我们通过使用Fragment和ViewPager模仿实现了微信的布局框架.今天我们来通过使用Li ...
- Android中Fragment和ViewPager那点事儿(仿微信APP)
在之前的博文<Android中使用ViewPager实现屏幕页面切换和引导页效果实现>和<Android中Fragment的两种创建方式>以及<Android中Fragm ...
- Android中Fragment与Activity之间的交互(两种实现方式)
(未给Fragment的布局设置BackGound) 之前关于Android中Fragment的概念以及创建方式,我专门写了一篇博文<Android中Fragment的两种创建方式>,就如 ...
- 【月入41万】Mono For Android中使用百度地图SDK
借助于Mono For Android技术,.Net开发者也可以使用自己熟悉的C#语言以及.Net来开发Android应用.由于Mono For Android把Android SDK中绝大部分类库都 ...
- mono for android中使用dapper或petapoco对sqlite进行数据操作
在mono for android中使用dapper或petapoco,很简单,新建android 类库项目,直接把原来的文件复制过来,对Connection连接报错部分进行注释和修改就可以运行了.( ...
- Android开发学习之路-Android中使用RxJava
RxJava的核心内容很简单,就是进行异步操作.类似于Handler和AsyncTask的功能,但是在代码结构上不同. RxJava使用了观察者模式和建造者模式中的链式调用(类似于C#的LINQ). ...
随机推荐
- Clover周报模块 -- 开发总结
2014年7月8日 00:16:05 一.切图 这次开发,切图花了不少时间,样式是用scss写的,第一次用,不过用着用着就发现它的强大,层级.作用域.重用等都非常的方便,还有考拉神器,用着真是爽!不过 ...
- WF学习
1.添加argument 类的argument必须先在表达式里面实例化 argument和variable 没有区别啊??????? http://msdn.microsoft.com/en-us/l ...
- Python学习笔记整理(三)Python中的动态类型简介
Python中只有一个赋值模型 一.缺少类型声明语句的情况 在Python中,类型是在运行过程中自动决定的,而不是通过代码声明.这意味着没有必要事声明变量.只要记住,这个概念实质上对变量,对象和它们之 ...
- iOS 两种方法实现左右滑动出现侧边菜单栏 slide view
现在很多的APP中都有slide view,左右滑动出现侧边菜单栏的功能,Weico这个应用就有. 网上有很多第三方的类库实现了这种效果,其实自己代码写的话也是很简单的,下面我将介绍两种方法实现s ...
- uml(1)--概述
面象对象的课程已经学到UML建模部分, 为了应付老师布置了的作业,须重新学习UML 故趁此机会将自己所学,所看做个记录,不为点赞, 只为加深记忆,加深理解…不是都说写一遍等于读十遍嘛…… 对于UML ...
- 安装notepad++之后怎样在鼠标右键上加上Edit with notepad++
在鼠标右键上加入使用notepad++编辑 我们在安装完notepad++文本编辑器之后,在一个文本文件上右键有时候并没有出现"使用notepad++编辑的选项",我们可以通过简单 ...
- append与remove的简单使用
点击Add More按钮页面会自动添加一个输入框和Remove按钮,点击Remove按钮则此行元素将被移除. <!DOCTYPE html> <html lang="en& ...
- #ifdef __cplusplus extern "C" {代码} 倒底是什么意思?
时常在cpp的代码之中看到这样的代码: #ifdef __cplusplus extern "C" { #endif //一段代码 #ifdef __cplusplus } # ...
- Linux环境下使用JFS文件系统
Linux环境下使用JFS文件系统 JFS是IBM公司为linux系统开发的一个日志文件系统.从IBM的实力及它对Linux的态度来看,JFS应该是未来日志文件系统中最具实力的一个文件系统. JFS提 ...
- poj3667---Hotel 线段树区间合并,区间更新
题意:有N个房间,M次操作.有两种操作(1)"1 a",表示找到连续的长度为a的空房间,如果有多解,优先左边的,即表示入住.(2)"2 b len",把起点为b ...