安卓:图片按钮,超链接,电话,地图方向?

安卓:图片按钮,超链接,电话,地图方向?

问题描述:

我有一个简单的应用程序,我放在一起为我的公司。我有,我已经创建,但似乎无法让他们正确地连接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.