我試圖在Facebook上分享內容創建AlertDialog錯誤在我的分享按鈕點擊時一個onClick
我麻煩一個onclick創建一個警告對話框,
((Button) findViewById(R.id.actuDetailsShareButton)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(ActuDetailActivity.this);
builder.setTitle("Partagez sur facebook");
WebView facebookWV = new WebView(ActuDetailActivity.this);
LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
facebookWV.setLayoutParams(lp);
facebookWV.loadUrl("https://m.facebook.com/sharer.php?u=http://www.lalal.com");
builder.setView(facebookWV);
builder.show();
}
});
這裏是我的logcat:
03-27 19:18:23.007: E/AndroidRuntime(24773): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
這裏是我的第二次嘗試:
Dialog dialog = new Dialog(ActuDetailActivity.this);
dialog.setContentView(R.layout.share_alert_dialog_layout);
dialog.setTitle("lolol");
dialog.setCancelable(true);
((TextView) dialog.findViewById(R.id.shareAlertDialogTextView)).setText("share on facebook");
((WebView) dialog.findViewById(R.id.shareAlertDialogWebView)).loadUrl("https://m.facebook.com/sharer.php?u=http://www.lalal.com");
dialog.show();
但我的web視圖在其他活動開身,這不是我想要什麼
我已經得到了同樣的效果比我的第二次嘗試,我的webview內置在其他活動 – 2012-03-27 17:40:10
工程就像一個魅力!非常感謝你 – 2012-03-27 17:58:41