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). ...
随机推荐
- angular ng-bind-html 对src路径失效 解决方案
json内容 ;<img src="/newsfile/1506271512489.jpg" width="600" height="450&q ...
- windows搭建redis记录
windows安装redis:http://www.cnblogs.com/linjiqin/archive/2013/05/27/3101694.html 30个常用的redis命令:http:// ...
- Python中unittest采用不同的参数组合产生独立的test case
我们在使用Python的unittest做自动化或者单元测试时,有时需要一个测试用例根据不同的输入.输出组合而执行多次,但是,unittest中一个用例只能有一组参数组合执行,如果采用循环的方式,在生 ...
- Git学习笔记01--初始化设置
1.查看git版本 $ git --version 2.设置用户姓名和邮箱 $ git config --global user.name “Craftor” $ git config --globa ...
- 让C程序更高效的10种方法
http://blog.jobbole.com/1198/ 代码之美,不仅在于为一个给定问题找到解决方案,而且还在代码的简单性.有效性.紧凑性和效率(内存).代码设计比实际执行更难 .因此,每一个程序 ...
- IOS 通过button获取cell
在使用tableview时,有时我们需要在cell中添加button和label,以便添加某项功能,而且往往点这个button的方法中需要知道button所在cell中label内存放的值. 一般而言 ...
- Activity生命周期的学习以及Logcat的使用
http://android.blog.51cto.com/268543/322518/ Activities是由Activity stack管理的.当一个新的Activity被启动,它就会处于st ...
- cf B. Maximum Absurdity
http://codeforces.com/contest/332/problem/B #include <cstdio> #include <cstring> #includ ...
- 装饰者模式 - OK
装饰模式(Decorator),动态地给一个对象添加一些额外的职责,就增加功能来说,装饰模式比生成子类更为灵活. 装饰者模式隐含的是通过一条条装饰链去实现具体对象,每一条装饰链都始于一个Compon ...
- 【Java】在JTable中设置鼠标监听器,点击操作对应数据
最终效果 鼠标点击JTable中任一数据,修改相应的信息. 确定点击的行和列 package com.dao; import java.awt.event.MouseAdapter; import j ...