如何添加在联系人列表按钮或菜单? [英] how to add button or Menu in Contacts list?

查看:92
本文介绍了如何添加在联系人列表按钮或菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的code,以开放的Andr​​oid通讯录

I am using following code to open Android Contacts

  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        btnContacts = (Button) findViewById(R.id.btn_contacts);   
        txtContacts = (TextView) findViewById(R.id.txt_contacts);   

        btnContacts.setOnClickListener(new OnClickListener() {   
            public void onClick(View arg0) {   
                txtContacts.setText("");
                Intent intent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);   
                startActivityForResult(intent, PICK_CONTACT);   
            }   
        });   
}



 @Override  
    public void onActivityResult(int reqCode, int resultCode, Intent data) {   
        super.onActivityResult(reqCode, resultCode, data);   

        switch (reqCode) {   
            case (PICK_CONTACT):   
                if (resultCode == Activity.RESULT_OK) {   

//display picked contact data.
}

}

}

现在我想把按钮,这个联络活动的顶部打开时或添加自己的菜单在此活动

Now I want to put Button at the top of this Contact activity when opened or add my own Menu in this Activity

任何一个可以指导我?这是可能的或没有?如果是的话,那么请告诉如何实现这一目标?

Can any one guide me? Is this possible or not? If yes then please tell how to achieve this?

推荐答案

我不相信这是可能的,在Android中每个活动正在自己和启动意图,你基本上是给新的活动焦点(和控制)。

I don't believe that is possible as each Activity in Android is working on its own and by starting the Intent, you are basically giving the new Activity the focus (and control).

做这样的事情,这将是建立一个使用公共数据提供访问联系人自定义联系人列表活动,并罗列了他们,那么一种方式。然后,只要你喜欢,你可以添加尽可能多的自定义功能,甚至增加意图原创的动作(如查看联系人的详细信息)。

One way to do something like this would be to build a custom contact list activity that uses the public data providers to access the contacts and simply lists them then. Then you could add as many custom functions as you like or even add Intents for original actions (like viewing a contact's details).

这篇关于如何添加在联系人列表按钮或菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆