读书人

个人Android札记(一)

发布时间: 2012-08-29 08:40:14 作者: rapoo

个人Android笔记(一)
1、Linkify规则:Linkify.addLinks(tv,Linkify.WEB_URL|Linkify.PHONE_NUMBERS)

2、打电话:Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:" + et.getText()));

3、拨号:Intent intent = new Intent(Intent.ACTION_DIAL);

4、getListView().setTextFilterEnabled(true);//List中允许使用a,b等键盘字母进行快速查询

5、完全退出程序:Android2.2版本
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
System.exit(0);//退出程序
Android2.2以下版本
1、在配置文件中加入权限:
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
  2、ActivityManager am = (ActivityManager)getSystemService (Context.ACTIVITY_SERVICE);
    am.restartPackage(getPackageName());

6、Activity无标题全屏模式
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

7、窗口类型的activity
android:theme = "@android:style/Theme.Dialog"

8、拆分短信,发送(直接发送出去,不调用系统的发送短信界面)



10、设置activity的背景色
(1)xml中实现:
android:background="@drawable/white"
white色定义在res/values中
(2)程序中实现:
Resources resource = getBaseContext().getResources();  Drawable hippoDrawable = resource.getDrawable(R.drawable.white);  TextView tv = (TextView)findViewByID(R.id.text);  tv.setBackground(hippoDrawable);

读书人网 >Android

热点推荐