安卓:图片按钮,超链接,电话,地图方向? [英] Android: Image button as a hyperlink, phone call, map directions?

查看:155
本文介绍了安卓:图片按钮,超链接,电话,地图方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的应用程序,我放在一起为我的公司。我有,我已经创建,但似乎无法让他们正确地连接4个按钮。一键应该打开我们的手机网站,另一个按钮给我们打电话,另一个按钮映射到我们,最终按钮链接到我们的新闻网站。任何帮助将大大AP preciated!

I have a simple app that I'm putting together for my company. I have 4 buttons that I've created but can't seem to get them to link correctly. One button should open our mobile site, another button to call us, another button to map to us, and the final button linked to our "News" site. Any help would be greatly appreciated!

推荐答案

在你的按钮,你应该设置OnClickListener,并做了一些你可以看到下面的例子中需要采取的行动:

On your buttons, you should set OnClickListener, and to do some required actions you could see the example below:

  1. 要打开一个地图与某个位置

  1. To Open a Map with Certain Location

mapButton.setOnClickListener(new OnClickListener(){
    @Override
    public void onClick(View v) {
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + your-location-geo-address));
        startActivity(i);
    }
});

  • 要拨打一定数量

  • To call certain number

    callButton.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + telephone-number));
            startActivity(i);
        }
    });
    

  • 要打开一个网站

  • To open a website

    linkButton.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(website-address));
            startActivity(i);
        }
    });
    

  • 更改所在地地址,电话号码和网站地址用自己的字符串值。 我希望这有助于。

    Change "location-address", "telephone-number", and "website-address" with your own String value. I hope this helps.

    这篇关于安卓:图片按钮,超链接,电话,地图方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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