【发布时间】:2015-06-16 02:28:13
【问题描述】:
我不知道如何在 android 应用程序上添加指向 facebook 页面的链接。 我已经有一个图像按钮,我希望它可以点击并将用户发送到我们的 Facebook 页面。 谢谢
【问题讨论】:
-
当您单击按钮时,打开浏览器并显示 facebook 页面。
标签: android facebook twitter hyperlink icons
我不知道如何在 android 应用程序上添加指向 facebook 页面的链接。 我已经有一个图像按钮,我希望它可以点击并将用户发送到我们的 Facebook 页面。 谢谢
【问题讨论】:
标签: android facebook twitter hyperlink icons
在你的布局中使用 WebView 并尝试一下
public void onClick(View v){
String url = "www.facebook.com";
mWebView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
}
【讨论】:
试试这样:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
addListenerOnButton();
}
public void addListenerOnButton() {
imageButton = (ImageButton) findViewById(R.id.imageButton1);
imageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.facebook.com"));
startActivity(browserIntent);
}
});
}
}
在 XML 布局中添加:
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/android_button" />
【讨论】: