Android:电话拨号器、呼叫记录、结束通话、Android显示单位
界面布局:
<?xml version="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:layout_width="fill_parent"android:layout_height="wrap_content"
android:text="@string/inputmobile"/>
<EditTextandroid:layout_width="fill_parent"android:layout_height="wrap_content"
android:id="@+id/mobile"/>
<Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"
android:text="@string/button"
android:id="@+id/button"/>
</LinearLayout>
AndroidManifest.xml中添加电话服务权限:<uses-permissionandroid:name="android.permission.CALL_PHONE"/>
Activity:
public class DialerAction extends Activity {
@Override
public void onCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button =(Button)findViewById(R.id.button);
button.setOnClickListener(newView.OnClickListener(){
publicvoid onClick(View v) {
EditTexteditText = (EditText)findViewById(R.id.mobile);
Intentintent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+editText.getText()));
DialerAction.this.startActivity(intent);
}
});
}
}
上面的数据来源于源码解读
删除呼叫记录
36
Android中的显示单位
一般HVGA代表320x480像素,这个用的比较多。
l dip 或 dp (device independent pixels) 设备独立像素这个和设备硬件有关,一般为了支持WVGA、HVGA和QVGA推荐使用这个,不依赖像素。
l sp (scaled pixels — best for textsize) 比例像素主要处理字体的大小,可以根据系统的字体自适应。
除了上面三个显示单位,下面还有几个不太常用:
l in (inches) 英寸 l mm (millimeters) 毫米 l pt (points) 点, 1/72 英寸 l为了适应不同分辨率,不同的像素密度,推荐使用dip,文字使用sp。
更多相关文章
- android 手机判断是否在充电 如断电自动打电话提醒功能
- Android之简易电话 & 短信
- Android长度单位详解(dp、sp、px、in、pt、mm、dip)
- Android之路——第一个Android小程序(Android电话拨号器)
- Android - 像素密度和屏幕适配
- Android 自定义像素AVD模拟器无键盘