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). ...
随机推荐
- ThinkPHP内置函数详解D、F、S、C、L、A、I
单字母函数D.F.S.C.L.A.I 他们都在ThinkPHP核心的ThinkPHP/Mode/Api/functions.php这个文件中定义. 下面我分别说明一下他们的功能: D() 加载Mode ...
- Android学习笔记--AlertDialog应用
1. 自定义实现带图标的TextView IconTextView.java package com.evor.andtest; import android.content.Context; imp ...
- iOS开发 - 不进入待机(屏幕保持唤醒)---UIApplication学习
iOS开发 - 不进入待机(屏幕保持唤醒)---UIApplication学习 如果你不希望应用运行时 iPhone 进入锁屏待机状态,加入下面这行代码即可 [[UIApplication share ...
- Delphi 函数指针(函数可以当参数)
首先学习: 指向非对象(一般的)函数/过程的函数指针 Pascal 中的过程类型与C语言中的函数指针相似,为了统一说法,以下称函数指针.函数指针的声明只需要参数列表:如果是函数,再加个返回值.例如声明 ...
- 深入理解Java的protected修饰符
其实Java的protected修饰符,权限定义的很微妙,大致有以下几种: (1)protected控制符用于修饰方法和成员变量: (2)一个类的protected方法或成员变量,在包外是不能通过该类 ...
- zoj3802:easy 2048 again(状压dp)
zoj月赛的题目,非常不错的一个状压dp.. 题目大意是一个一维的2048游戏 只要有相邻的相同就会合并,合并之后会有奖励分数,总共n个,每个都可以取或者不取 问最终得到的最大值 数据范围n<= ...
- HDU 3586 : Information Disturbing
Problem Description In the battlefield , an effective way to defeat enemies is to break their commun ...
- VC++中的类的内存分布(上)
0.序 目前正在学习C++中,对于C++的类及其类的实现原理也挺感兴趣.于是打算通过观察类在内存中的分布更好地理解类的实现.因为其实类的分布是由编译器决定的,而本次试验使用的编译器为VS2015 RC ...
- c++之命名空间namespace
1命名空间解决全局变量的冲突 main.h文件 #pragma once // data命名空间的名称 namespace data { ;//外部全局变量冲突 } main.cpp #include ...
- 第19讲- UI组件之_Button、checkbox、radio
第19讲 UI组件之_Button.checkbox.radio 四.按钮Button Button继承自TextView,间接继承自View.当用户对按钮进行操作的时候,触发相应事件,如点击,触摸. ...