PopupWindow:
@Override
public void onWindowFocusChanged(boolean hasFocus)
{
try
{
int[] location = new int[2];
(xml item where you want it to appear).getLocationOnScreen(location);
//Get x and y positions
p = new Point();
p.x = location[0];
p.y = location[1];
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void popTab(final Activity myActivity)
{
popupWidth = 350;
popupHeight = 600;
popup.setWidth(popupWidth);
popup.setHeight(popupHeight);
// Inflate the popup_layout.xml
LinearLayout viewGroup = (LinearLayout) myActivity.findViewById(R.id.myMainLayoutID);
LayoutInflater layoutInflater = (LayoutInflater) myActivity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layoutTab = layoutInflater.inflate(R.layout.mylayout, viewGroup);
//Get webview from xml
WebView wv = (WebView)layoutTab.findViewById(R.id.webView2);
// Creating the PopupWindow
final PopupWindow popup = new PopupWindow(layoutTab);
//Set to view
popup.setContentView(layoutTab);
//Setup webview
wv.loadUrl("http:\\www.google.com");
wv.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
//Add some animation from style folder
popup.update();
popup.setAnimationStyle(R.style.Animation);
popup.setFocusable(true);
popup.showAtLocation(layoutTab, Gravity.NO_GRAVITY, p.x, p.y);
}
Sử dụng popTab() có bao giờ bạn như. Hy vọng điều này sẽ giúp với cửa sổ bật lên.
cảm ơn nó thực sự làm việc ngay bây giờ với alertdialog, tại sao nó bây giờ làm việc với popupwindow cũng? - user1194088 vừa mới –
không hoạt động với popupwindow? –
Điều gì sẽ xảy ra nếu tôi muốn hiển thị chỉ báo tải trong khi tải trang? – user1940676