QuickContactBadge继承了ImageView,因此它的本质也是图片按钮,也可以通过android:src属性指定它显示的图片。QuickContactBadge额外增加的功能是:该图片可以关联到手机中指定联系人,当用户单击该图片时,系统将会打开相应联系人的联系方式界面。
为了让QuickContactBadge与特定联系人关联,可调用如下方法。
assignContactFromEmail(String emailApp\src\main\ress,boolen lazyLookup):将该图片关联到指定E-MAIL地址对应的联系人。
assignContactFromPhone(String phoneNumber,boolean lazyLookup):将该图片关联到指定电话号码对应的联系人。
assignContactUrl(Uri contactUri):将该图片关联到特定的Uri对应的联系人。
示范:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.dezai.quickcontactbadgetest.MainActivity">
<QuickContactBadge
android:id="@+id/badge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:text="我的偶像"/>
</LinearLayout>
Activity代码:
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("15980930768",false);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。