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(安卓)ToastUtil
- Android顶部用tabLayout和viewPager显示二级分类
- android之ListView和adapter配合显示图片和文字列表
- Android显示GIF动画的几种方法
- android典型代码系列(六)------drawable图片转换为48dip的bitmap
- Android(安卓)设置字体大小和显示大小后界面混乱
- 【Android代码片段之三】TabActivity实现多页显示效果
- Activity切换 窗口绘制显示
- Android在Gallery中每次滑动只显示一页