简体   繁体   English

如何在Android应用程序上集成Facebook页面?

[英]how to integrate facebook page on android application?

I don't know how to add a link that goes to a page facebook on android application. 我不知道如何在Android应用程序中添加指向Facebook页面的链接。 I have already an image button that i want to be clickable and send the user to our facebook page. 我已经有一个想要单击的图像按钮,并将用户发送到我们的Facebook页面。 thanks 谢谢

Take WebView in your layout and try this 在您的布局中使用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;
            }
        });
    }

Try like this: 尝试这样:

 @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); } }); } } 

Add this in XML Layout: 在XML布局中添加此代码:

  <ImageButton android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" /> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM