Android:电话拨号器、呼叫记录、结束通话、Android显示单位

来源:互联网 发布:比钉钉好用的软件 编辑:程序博客网 时间:2024/04/30 03:04

界面布局:

<?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中的显示单位


lpx(pixels)像素

    一般HVGA代表320x480像素,这个用的比较多。

l dipdp (device independent pixels)设备独立像素

   这个和设备硬件有关,一般为了支持WVGAHVGAQVGA推荐使用这个,不依赖像素。

l sp (scaled pixels — best for textsize)比例像素

   主要处理字体的大小,可以根据系统的字体自适应。

除了上面三个显示单位,下面还有几个不太常用:

l in (inches)英寸
l mm (millimeters)毫米 
l pt (points)点,1/72英寸
l

为了适应不同分辨率,不同的像素密度,推荐使用dip,文字使用sp


0 0