how to add button or Menu in Contacts list?

▼魔方 西西 提交于 2020-01-06 06:02:57

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/2833270/how-to-add-button-or-menu-in-contacts-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!