- 浏览: 362717 次
- 性别:
- 来自: 深圳
-
最新评论
-
yuantingjun:
老大,能参考下代码吗?
2天弄了个个人网站 -
yuantingjun:
这么牛啊。 膜拜一二
2天弄了个个人网站 -
guzizai2007:
toknowme 写道兄弟,在哪里买的空间啊~求链接~~阿里云 ...
2天弄了个个人网站 -
toknowme:
兄弟,在哪里买的空间啊~求链接~~
2天弄了个个人网站 -
haoran_10:
不错,赞一个
2天弄了个个人网站
文章列表
SharedPreference
- 博客分类:
- Android
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"
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 ...
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 ...
viewholder的使用
Adapter的作用就是ListView界面与数据之间的桥梁,当列表里的每一项显示到页面时,都会调用Adapter的getView方法返回一个View。 优化的思路两种: 1. View的重用 View的每次创建是比较耗时的,因此对于getview方法传入的convertView应充分利用 != null的判断 2.ViewHolder的应用 View的findViewById()方法也是比较耗时的,因此需要考虑只调用一次,之后就用View.getTag()方法来获得ViewHolder对象。
package com.example.andro ...
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. ...
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 ...
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 ...
android:layout_marginLeft="29dp" // 左边距
android:layout_marginTop="42dp" // 上边距
android:textSize="20sp" // 字体大小
android:text="@string/button1" 不要硬编码
控件用dp 字体用sp
android:paddingLeft="40dp" // 内左边距
android:hint="hello world" / ...
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 ...
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
- 博客分类:
- Android
管理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
- 博客分类:
- Android
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
- 博客分类:
- Android
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请求的两个阶段:
等待资源阶段:IO请求一般需要请求特殊的资源(如磁盘、RAM、文件),当资源被上一个使用者使用没有被释放时,IO请求就会被阻塞,直到能够使用这个资源。
使用资源阶段:真正进行数据接收和发生。
举例说就是排队和服务。
在等待数据阶段,IO分为阻塞IO和非阻塞IO。
阻塞IO:资源不可用时,IO请求一直阻塞,直到反馈结果(有数据或超时)。
非阻塞IO:资源不可用时,IO请求离开返回,返回数据标识资源不可用
在使用资源阶段,IO分为同步IO和异步IO。
同步IO:应用阻塞在发 ...