您的位置:首页 > 产品设计 > UI/UE

安卓案例-使用QuickContactBadge 关联联系人

2016-12-12 16:46 483 查看
QuickContactBadge 继承了 ImageView 因此它的本质也是图片按钮,也可以通过 android:src 属性指定它显示的图片。QuickContactBadge 额外增加的功能是:该图片可以关联到手机中指定联系人,当用户单机该图片的时候,系统将会打开相应联系人的联系方式界面。

QuickContactBadge 需要调用的方法

assignContactFromEmail(String emailAddapp\src\main\ress,boolean lazyLookup):将该图片关联到指定 E-mail 地址对应的联系人

assignContactFromPhone(String phoneNumber,boolean lazyLookup):将该图片关联到指定电话号码对应的联系人

assignContactUri(Uri contactUri) 将该图片关联到特定 Uri 对应的联系人

本案例效果图如下



布局文件代码如下

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="pub.weber.bym.quickcontactbadge.MainActivity">

<QuickContactBadge
android:id="@+id/badge"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/c"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:text="weber开发者"/>
</LinearLayout>


MainActivity 代码如下

public class MainActivity extends AppCompatActivity {

QuickContactBadge badge;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
badge = (QuickContactBadge) findViewById(R.id.badge);
badge.assignContactFromPhone("110-12345678",false);
}
}


by web开发者 更多相关内容请访问: http://weber.pub/

本文地址: http://weber.pub/安卓笔记19(案例)-使用qui…ntactbadge-关联联系人/330.html

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息