开发者

how to add button or Menu in Contacts list?

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜