0
我的佈局很好,只剩下幾個問題:我無法使用mailto和facebook鏈接按鈕。這是我已經試過:Android上的按鈕問題
ImageView Button = (ImageView)findViewById(R.id.yourButtonsId);
Button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http://www.yourURL.com"));
startActivity(intent);
}
});
和
TextView textView = (TextView)findViewById(R.id.yourID);
textView.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http://www.typeyourURL.com"));
startActivity(intent);
} });
嗨,感謝您的迴應,但我該如何使用此代碼?我必須爲此做一個xml嗎? im在mainactivity.xml我不知道如何解決android – err0r
把它放到onClick() – ZeroOne