首页 文章 精选 留言 我的

精选列表

搜索[移动开发],共10010篇文章
优秀的个人博客,低调大师

PhoneGap 1.8.1 发布,跨平台移动开发框架

PhoneGap官方今天发布了PhoneGap 1.8.1版本,主要修复了1.8版本中导致iOS平台上PhoneGap应用程序崩溃的bug。 该版本相对于之前的1.7版本,主要修复了iOS、Android、Windows Phone、黑莓和WebOS平台上的大量bug,此外还进行了大量的改进,部分如下: iOS:添加HTTP状态码到FileTransferError对象 iOS:升级地理位置功能,以和W3C规范一致 iOS:新增记录器插件 iOS:重写了加速器插件,简化了该插件的启动/停止行为 Android:当删除图像文件时查询Andoid content数据库 Android:在FileUtils.notifyDelete中使用stripFileProtocol协议 Android:修复了一些示例中出现的问题 WP:允许创建新的命令行界面项目 WP:重写了加速器插件 文章转载自 开源中国社区 [http://www.oschina.net]

优秀的个人博客,低调大师

【移动开发】Android中Theme和Style的使用

当我们做项目到一定程度的时候,Android提供给我们的简单的UI控件(虽然后期ADT插件更新中增加了不少)已经不能满足我们的需要,一款成功的软件不仅要功能强大,漂亮的界面同样会吸引不少用户! 这里,我将总结一下Android提供给我们的两个重要的资源:Theme 和 Style。 1.Theme(是针对窗体级别的,可以改变窗体样式) 官方文档 Themes are Android's mechanism for applying a consistent style to an app or activity. The style specifies the visual properties of the elements that make up your user interface, such as color, height, padding and font size. To promote greater cohesion between all apps on the platform, Android provides three system themes that you can choose from when building apps for Ice Cream Sandwich: 主题是Android的机制被应用一个相同风格的应用程序或Activity中。样式指定了视觉属性的元素装饰你的用户界面,如颜色、高度、填充和字体大小。促进更大的凝聚力在所有平台的应用程序,Android提供了三个系统的主题,您可以选择在构建应用程序选择不同的主题: Holo Light Holo Dark Holo Light with dark action bars 官方图: 1.1.使用 Android系统的themes.xml和style.xml(位于/base/core/res/res/values/)包含了很多系统定义好的style,建议在里面挑个合适的,然后再继承修改。以下属性是在Themes中比较常见的,源自Android系统本身的themes.xml: 1 2 3 4 5 6 7 8 < style name = "simple_dialog" parent = "@android:style/Theme.Dialog" > < item name = "android:windowFrame" >@null</ item > <!-- Dialog的WindowFrame框为无 --> < item name = "android:windowNoTitle" >true</ item > < item name = "android:windowIsFloating" >true</ item > <!-- 是否悬浮在activity上 --> < item name = "android:windowIsTranslucent" >true</ item > <!-- 是否半透明 --> < item name = "android:backgroundDimEnabled" >false</ item > <!-- 背景是否模糊 --> </ style > 有人会问从哪里学习这些主题?其实系统就自带了很多,看下图: 在AndroidManifest的Application中,点击Theme选项,系统资源里就有相当多的主题供你选择。 A.应用到Application 1 <application android:theme= "@style/CustomTheme" > B.应用到Activity 1 <activity android:theme= "@android:style/Theme.Dialog" > 2.Style(是针对窗体元素级别的,改变指定控件或者Layout的样式) 官方文档: A style is a collection of properties that specify the look and format for a View or window. A style can specify properties such as height, padding, font color, font size, background color, and much more. A style is defined in an XML resource that is separate from the XML that specifies the layout. 风格是一个集合的属性用于指定具有一定外观和格式的视图或窗口。一个风格可以指定属性如高度、填充、字体颜色、字体大小、背景色等等。一个样式定义在XML资源,独立于XML指定布局。 Styles in Android share a similar philosophy to cascading stylesheets in web design—they allow you to separate the design from the content. 风格在安卓中的份额就如同级联样式表在web设计中的设计,允许你将内容分割开来设计 2.1简单使用 一个简单地样式 1 2 3 4 5 6 < TextView android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:textColor = "#00FF00" android:typeface = "monospace" android:text = "@string/hello" /> 可以在任何相同的地方被引用 1 2 3 <TextView style= "@style/CodeFont" android:text= "@string/hello" /> 2.2定义风格 首先可以在res/values/下创建一个xml,用于定义style(注意:根结点必须是<resources>) 1 2 3 4 5 6 7 8 9 <? xml version = "1.0" encoding = "utf-8" ?> < resources > < style name = "CodeFont" parent = "@android:style/TextAppearance.Medium" > < item name = "android:layout_width" >fill_parent</ item > < item name = "android:layout_height" >wrap_content</ item > < item name = "android:textColor" >#00FF00</ item > < item name = "android:typeface" >monospace</ item > </ style > </ resources > 这里我们可以看到,该style的名称为CodeFont,parent后面是父类的style,(当然,我们也可以不用继承父类style),接下来每一个item定义一个属性。定义属性的最好方法就是在api文档里找到这个view的xml属性,比如在EditText中有InputType这个属性,那么在你的style里面你就可以来定义它。 ok! 就是这些了! 本文转自zhf651555765 51CTO博客,原文链接:http://blog.51cto.com/smallwoniu/1251507 ,如需转载请自行联系原作者

优秀的个人博客,低调大师

【移动开发】Android中Fragment+ViewPager的配合使用

原本在上一篇博客中要讲解一个Fragment的综合应用,但是中间又想到了滑屏方式,所以就分类在总结了一下,(http://smallwoniu.blog.51cto.com/3911954/1308959)今天我将继续总结,关于Fragment+ViewPager的使用! 官方文档:http://developer.android.com/reference/android/support/v4/view/ViewPager.html ViewPager is most often used in conjunction withFragment, which is a convenient way to supply and manage the lifecycle of each page. There are standard adapters implemented for using fragments with the ViewPager, which cover the most common use cases. These areFragmentPagerAdapterandFragmentStatePagerAdapter; each of these classes have simplecode showing how to build a full user interface with them. 这里大家可以回忆一下如果像上篇中介绍ViewPager的使用,叶片填充数据是Layout,页面少的话还可以,如果页面过多的话,全部加载到手机内存中,可能会耗尽内存,手动销毁又太麻烦。官方推荐ViewPager与Fragment一起使用,可以更加方便的管理每个Page的生命周期,这里有标准的适配器实现用于ViewPager和Fragment,涵盖最常见的用例。FragmentPagerAdapter和FragmentStatePagerAdapter这两个类都有简单的代码显示如何构建一个完整的用户界面与他们。 适配器类: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 package com.zhf.android_viewpager_fragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; /** * 自定义fragment适配器 * @author ZHF * */ public class MyFragmentPageAdapter extends FragmentPagerAdapter { public MyFragmentPageAdapter(FragmentManager fm) { super (fm); } @Override public int getCount() { return 3 ; } @Override public Fragment getItem( int position) { switch (position) { case 0 : return MyFragment.newInstance(position); case 1 : return MyFragment.newInstance(position); case 2 : return MyFragment.newInstance(position); default : return null ; } } } MyFragment类: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 package com.zhf.android_viewpager_fragment; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; /** * 用于创建Fragment对象,作为ViewPager的叶片 * @author ZHF * */ public class MyFragment extends Fragment { int mNum; //页号 public static MyFragment newInstance( int num) { MyFragment fragment = new MyFragment(); // Supply num input as an argument. Bundle args = new Bundle(); args.putInt( "num" , num); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); //这里我只是简单的用num区别标签,其实具体应用中可以使用真实的fragment对象来作为叶片 mNum = getArguments() != null ? getArguments().getInt( "num" ) : 1 ; } /**为Fragment加载布局时调用**/ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_pager_list, null ); TextView tv = (TextView) view.findViewById(R.id.text); tv.setText( "fragment+" + mNum); return view; } } 布局文件: activity_main.xml 1 2 3 4 5 6 7 8 9 10 <RelativeLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http://schemas.android.com/tools" android:layout_width= "match_parent" android:layout_height= "match_parent" > <android.support.v4.view.ViewPager android:id= "@+id/viewpager" android:layout_width= "fill_parent" android:layout_height= "fill_parent" /> </RelativeLayout> fragment_pager_list.xml 1 2 3 4 5 6 7 8 9 10 11 12 13 <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "match_parent" android:layout_height= "match_parent" android:background= "@android:drawable/gallery_thumb" android:orientation= "vertical" > <TextView android:id= "@+id/text" android:layout_width= "match_parent" android:layout_height= "wrap_content" android:gravity= "center_vertical|center_horizontal" android:text= "@string/hello_world" android:textAppearance= "?android:attr/textAppearanceMedium" /> </LinearLayout> MainActivity类: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 package com.zhf.android_viewpager_fragment; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; public class MainActivity extends FragmentActivity { private ViewPager mViewPager; private MyFragmentPageAdapter mAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.viewpager); //这里因为是3.0一下版本,所以需继承FragmentActivity,通过getSupportFragmentManager()获取FragmentManager //3.0及其以上版本,只需继承Activity,通过getFragmentManager获取事物 FragmentManager fm = getSupportFragmentManager(); //初始化自定义适配器 mAdapter = new MyFragmentPageAdapter(fm); //绑定自定义适配器 mViewPager.setAdapter(mAdapter); } } 效果图: 效果与ViewPager中添加View的效果是一样的!但是它与View的区别在于它有自己的生命周期,可以随时更改自己的状态便于管理。 事实上使用FragmentPagerAdapter时,Fragment对象会一直存留在内存中,所以当有大量的显示页时,就不适合用FragmentPagerAdapter了,FragmentPagerAdapter适用于只有少数的page情况,像选项卡。 这个时候你可以考虑使用FragmentStatePagerAdapter,当使用FragmentStatePagerAdapter时,如果Fragment不显示,那么Fragment对象会被销毁,(滑过后会保存当前界面,以及下一个界面和上一个界面(如果有),最多保存3个,其他会被销毁掉)但在回调onDestroy()方法之前会回调onSaveInstanceState(Bundle outState)方法来保存Fragment的状态,下次Fragment显示时通过onCreate(Bundle savedInstanceState)把存储的状态值取出来,FragmentStatePagerAdapter比较适合页面比较多的情况,像一个页面的ListView。 本文转自zhf651555765 51CTO博客,原文链接:http://blog.51cto.com/smallwoniu/1322746,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册