`
guzizai2007
  • 浏览: 354285 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论
文章列表

SharedPreference

package com.example.android_shared_preference; import android.app.Activity; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.view.Menu; import android.widget.EditText; import android.widget.TextView; /** ...

横竖屏切换

// 切换横屏 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // 切换竖屏 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);   android:screenOrientation="landscape"  

Layout1.9

GridView android:numColumns="auto_fit"  列数  自动设置 android:columnWidth="90dp" 列宽 android:verticalSpacing="10dp" 行间距 android:horizontalSpacing="10dp" 列间距 android:stretchMode="columnWidth" 缩放方式 package com.example.android_grid_layout; import an ...

Layout1.8

ListView刷新分页: package com.example.android_listview_activity; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListVi ...

Layout1.7

viewholder的使用 Adapter的作用就是ListView界面与数据之间的桥梁,当列表里的每一项显示到页面时,都会调用Adapter的getView方法返回一个View。 优化的思路两种: 1. View的重用     View的每次创建是比较耗时的,因此对于getview方法传入的convertView应充分利用 != null的判断 2.ViewHolder的应用 View的findViewById()方法也是比较耗时的,因此需要考虑只调用一次,之后就用View.getTag()方法来获得ViewHolder对象。    package com.example.andro ...

Layout1.6

ListView BaseAdapter: package com.example.android_listview_activity; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android. ...

Layout1.5

ListView图文列表:  item模板 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientati ...

Layout1.4

ListView单选: package com.example.android_listview_activity; import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; public class MainActivity2 extends Activity{ private ListView listView; @Override protected void ...

Layout1.3

android:layout_marginLeft="29dp"  // 左边距  android:layout_marginTop="42dp"  // 上边距 android:textSize="20sp" // 字体大小 android:text="@string/button1"  不要硬编码 控件用dp  字体用sp   android:paddingLeft="40dp"  // 内左边距  android:hint="hello world"  / ...

Layout1.2

Relative Layout If you find yourself using several nested LinearLayout groups, you may be able to replace them with a single RelativeLayout.   RelativeLayout is a view group that displays child views in relative positions   android:layout_alignParentTopIf "true", makes the top edge of ...

Layout1.1

Write the XML Each layout file must contain exactly one root element, which must be a View or ViewGroup object   <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_wi ...

Activity1.3

管理Activity的生命周期 你可以通过调用finish() 来终止activity   An activity can exist in essentially three states: Resumed:The activity is in the foreground of the screen and has user focus(在屏幕的前面或者获取用户焦点)   Paused:Another activity is in the foreground and has focus, but this one is still visible,the 

Activity1.2

Starting an Activity You can start another activity by calling startActivity() The intent specifies either the exact activity you want to start or describes the type of action you want to perform   An intent can also carry small amounts of data to be used by the activity that is started.   pac ...

Activity1.1

An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map.   An application usually consists of multiple activities   Each time a new activity starts, the previous act ...

IO模型

    博客分类:
  • Java
IO请求的两个阶段:        等待资源阶段:IO请求一般需要请求特殊的资源(如磁盘、RAM、文件),当资源被上一个使用者使用没有被释放时,IO请求就会被阻塞,直到能够使用这个资源。        使用资源阶段:真正进行数据接收和发生。        举例说就是排队和服务。  在等待数据阶段,IO分为阻塞IO和非阻塞IO。        阻塞IO:资源不可用时,IO请求一直阻塞,直到反馈结果(有数据或超时)。        非阻塞IO:资源不可用时,IO请求离开返回,返回数据标识资源不可用  在使用资源阶段,IO分为同步IO和异步IO。        同步IO:应用阻塞在发 ...
Global site tag (gtag.js) - Google Analytics