随笔分类 - android
使用活动首选项保存活动状态
摘要:1、创建或检索活动首选项对象SharedPreferences uiState = getPreferences(MODE_PRIVATE);2、获取活动首选项编辑器SharedPreferences.Editor editor = uiState.edit();3、添加活动首选项的值editor.putString(TEXT_ENTRY_KEY, myEditText.getText().toString());editor.putBoolean(ADDING_ITEM_KEY, addingNew);editor.commit();4、当活动不是正常退出时会触发@Overridepubli
阅读全文
SharedPreferences的通俗解析:
摘要:SharedPreferences的通俗解析: 很多时候我们开发的软件需要向用户提供软件参数设置功能,例如我们常用的QQ,用户可以设置是否允许陌生人添加自己为好友。对于软件配置参数的保存,如果是window软件通常我们会采用ini文件进行保存,如果是j2se应用,我们会采用properties属性文件进行保存。如果是Android应用,我们最适合采用什么方式保存软件配置参数呢?Android平台给我们提供了一个SharedPreferences类,它是一个轻量级的存储类,特别适合用于保存软件配置参数。使用SharedPreferences保存数据,其背后是用xml文件存放数据,文件存放在/da
阅读全文
【转】SharedPreferences
摘要:很多时候我们开发的软件需要向用户提供软件参数设置功能,例如我们常用的QQ,用户可以设置是否允许陌生人添加自己为好友。对于软件配置参数的保存,如果是window软件通常我们会采用ini文件进行保存,如果是j2se应用,我们会采用properties属性文件进行保存。如果是Android应用,我们最适合采用什么方式保存软件配置参数呢?Android平台给我们提供了一个SharedPreferences类,它是一个轻量级的存储类,特别适合用于保存软件配置参数。使用SharedPreferences保存数据,其背后是用xml文件存放数据,文件存放在/data/data/<package name
阅读全文
创建自定义布局的AlertDialog
摘要:1、创建LayoutInflaterLayoutInflater li=LayoutInflater.from(this);2、填充布局View quakeDetailsView=li.inflate(R.layout.quake_details, null);3、创建AlertDialogAlertDialog.Builder quakeDialog=new AlertDialog.Builder(this); AlertDialog的构造函数都是protect的,android只提供了AlertDialog.Builder来构造AlertDialog4、设置AlertDialog自定义视图
阅读全文
【转】LayoutInflater详解
摘要:LayoutInflater 一般来讲,我们用LayoutInflater做一件事:inflate。inflate这个方法总共有四种形式,目的都是把xml表述的layout转化为View。This class is used to instantiate layout XML file into its corresponding View objects. It is never be used directly -- use getLayoutInflater() or getSystemService(String)getLayoutInflater() or getSystemServ
阅读全文
【转】Java中Split函数的用法技巧
摘要:转自:http://www.cnblogs.com/liubiqu/archive/2008/08/14/1267867.html在java.lang包中也有String.split()方法,与.net的类似,都是返回是一个字符型数组,但使用过程中还有一些小技巧。如执行:"2|33|4".split("|")出来的结果是:""2|33|4奇怪吧,不过注意看一下API说明还是知道原因的.java.lang.string.split split 方法 将一个字符串分割为子字符串,然后将结果作为字符串数组返回。 stringObj.spli
阅读全文
自定义ArrayAdapter示例
摘要:主要步骤1、编写ToDoItem类,重写其toString方法2、写一个子类继承于ArrayAdapter<ToDoItem>重写其public View getView(int position, View convertView,ViewGroup parent)方法用于返回每一项的View@OverridepublicViewgetView(intposition,ViewconvertView,ViewGroupparent){LinearLayouttodoView;ToDoItemitem=getItem(position);StringtaskString=item.
阅读全文
【转】Android 中LayoutInflater的使用
摘要:大家好我们这一节讲的是LayoutInflater的使用,在实际开发种LayoutInflater这个类还是非常有用的,它的作用类似于 findViewById(),不同点是LayoutInflater是用来找layout下xml布局文件,并且实例化!而findViewById()是找具体xml下的具体 widget控件(如:Button,TextView等)。为了让大家容易理解我做了一个简单的Demo,主布局main.xml里有一个TextView和一个Button,当点击Button,出现 Dialog,而这个Dialog的布局方式是我们在layout目录下定义的custom_dialog
阅读全文
anndroid 之 Intent(意图)使用示例
摘要:/Files/cappuccino/ContactPicker.rar
阅读全文
android寻找最适合资源过程
摘要:When you request a resource for which you provide alternatives, Android selects which alternative resource to use at runtime, depending on the current device configuration. To demonstrate how Android selects an alternative resource, assume the following drawable directories each contain different ve
阅读全文
Screen Size ratio
摘要:There is a 3:4:6:8 scaling ratio between the four primary densities (ignoring the tvdpi density). So, a 9x9 bitmap in ldpi is 12x12 in mdpi, 18x18 in hdpi and 24x24 in xhdpi.If you decide that your image resources don't look good enough on a television or other certain devices and want to try tv
阅读全文
port and land
摘要:portland square -->port: Device is in portrait orientation (垂直)land: Device is in landscape orientation (水平)
阅读全文
android:largestWidthLimitDp
摘要:android:largestWidthLimitDp This attribute allows you to force-enable screen compatibility mode by specifying the maximum "smallest width" that your application supports. If the smallest side of a device's available screen is greater than your value here, the application runs in screen
阅读全文
smallestWidth may use value
摘要:smallestWidthsw<N>dpExamples:sw320dpsw600dpsw720dpetc. Some values you might use here for common screen sizes:320, for devices with screen configurations such as: 240x320 ldpi (QVGA handset)320x480 mdpi (handset)480x800 hdpi (high density handset)480, for screens such as 480x800 mdpi (tablet/h
阅读全文
dp如何转换成准确的分辨率
摘要:Converting dp units to pixel unitsIn some cases, you will need to express dimensions in dp and then convert them to pixels. Imagine an application in which a scroll or fling gesture is recognized after the user's finger has moved by at least 16 pixels. On a baseline screen, a user's must mov
阅读全文
一个根据android mark上的软件实时统计7天内对于不同大小不同分辨率的设备的支持的百分比的网站
摘要:http://developer.android.com/resources/dashboard/screens.html
阅读全文
android中不同宽度大小比例
摘要:android中size small:normal:large:xlarge=3:4:6:8
阅读全文
android不同屏幕和分辨率的支持讨论
摘要:路径http://developer.android.com/guide/practices/screens_support.html#strategies http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources
阅读全文
Activity的活动Menu和上下文Menu使用示例
摘要:步骤1、重写Activity中的publicvoidonCreateContextMenu(ContextMenumenu,Viewv,ContextMenu.ContextMenuInfomenuInfo){super.onCreateContextMenu(menu,v,menuInfo);}创建Activity下方的menu菜单2、创建上下文的Menu(1)重写privateListViewmyListView;publicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);myListVie
阅读全文
drawable之scale and rotate代码示例
摘要:代码:/Files/cappuccino/ScaleAndRoteDrawable.rar
阅读全文
浙公网安备 33010602011771号