我想在mainactivity中单击后退按钮时添加退出警告.为此,我使用此代码
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
final Dialog dialoge=new Dialog(MainActivity.this,android.R.style.Theme_Translucent_NoTitleBar);
dialoge.setContentView(R.layout.popup_layout);
Button yes=(Button)dialoge.findViewById(R.id.yes);
yes.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
MainActivity.this.finish();
}
});
Button no=(Button)dialoge.findViewById(R.id.no);
no.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
dialoge.cancel();
}
});
dialoge.show();
}
Run Code Online (Sandbox Code Playgroud)
这是有效的,但退出时显示一些错误.
Logcat是
03-21 10:25:57.192: E/WindowManager(14488): Activity com.example.design.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@447fec28 that was originally added here
03-21 10:25:57.192: E/WindowManager(14488): android.view.WindowLeaked: Activity com.example.design.MainActivity has leaked …
Run Code Online (Sandbox Code Playgroud) 我想在JavaFX中创建特定的组件.在onClick事件后显示poupup的按钮.
Scnenario:
我们点击按钮
弹出窗口显示按钮(如图所示)
看到这个小提琴,如何在父母和孩子中没有固定宽度和高度的蓝色div居中?
这是在SO中发布的
<div class="parent">
<div class="child">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这些是定位元素,我希望孩子在屏幕的中心.
看到它在这里居中,但我不能在父母和儿童中使用固定的宽度和高度.我需要定位元素,因为我需要它们超过其他元素.
我有像下面这样的弹出窗口类.
public class Popup extends PopupWindow {
Context context;
EditText et_bankname, et_banknumber;
String bank_name, account_number;
public Popup(Context ctx) {
super(ctx);
context = ctx;
setContentView(LayoutInflater.from(context).inflate(R.layout.bank_details, null));
setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
View popupView = getContentView();
setFocusable(true);
Button btn_close = (Button) popupView.findViewById(R.id.popupClose);
Button btn_submit = (Button) popupView.findViewById(R.id.popupSave);
et_bankname = (EditText) popupView.findViewById(R.id.bank_name);
et_banknumber = (EditText) popupView.findViewById(R.id.bankacc_no);
btn_submit.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
bank_name = et_bankname.getText().toString();
account_number = et_banknumber.getText().toString();
if (!bank_name.equals("") && !account_number.equals("")) {
Toast t1 = Toast.makeText(context,bank_name + " "+account_number , Toast.LENGTH_SHORT);
t1.setGravity(Gravity.TOP, 0, …
Run Code Online (Sandbox Code Playgroud) 理想情况下,当我单击我的表中的一个操作项时,它显示"显示消息"点击它我需要一个弹出窗口而不使用window.alert或alert显示根据我的网站设计弹出
function showFailedWarning(){
dijit.byId('validationsForm').clearMessages();
dijit.byId('validationsForm').popup(alert("Upload Correct File "));
}
Run Code Online (Sandbox Code Playgroud) 如果我想on_press
在任何程序中向弹出窗口添加事件,我可以直接在python中或使用kv语言.
例如,如果我使用Python
from kivy.app import App
from kivy.uix.popup import Popup
from kivy.uix.button import Button
class SomePopup(Popup):
pass
class SomeBox(Box):
popup = SomePopup()
popup.title = 'anything'
popup.content = Button(text='anytext', on_press=popup.dismiss)
Run Code Online (Sandbox Code Playgroud)
在KV语言中,假设我制作相同的弹出窗口,它将是.
<SomePopup>
title: 'anything'
content: popupContent
Button:
id: popupContent
text: 'anytext'
on_press: root.dismiss()
Run Code Online (Sandbox Code Playgroud)
所以,在python中,我必须使用on_press=popup.dismiss
和kv语言on_press: root_dismiss()
我不明白为什么在kivy语言中我应该使用括号而不是python.请问你能帮帮我吗?
当我单击页面上的按钮(在IE浏览器中)时,将打开一个新的弹出页面.我尝试获取此弹出窗口的窗口句柄失败了.这是我的第一次尝试:
String baseWin = driver.getWindowHandle();
System.out.println(baseWin);
Set<String>s = driver.getWindowHandles();
Iterator<String> ite = s.iterator();
while ( ite.hasNext() ) {
String popUpHandle = ite.next();
if(!baseWin.equals(popUpHandle)) {
driver.switchTo().window(popUpHandle);
System.out.println(driver.switchTo().window(popUpHandle).getTitle());
Run Code Online (Sandbox Code Playgroud)
此尝试仅打印基本窗口的句柄,如果第二个print语句放在if()语句之外,但在while()语句之内和if()语句之后,它只是输出基本窗口的标题.所以句柄集似乎只包含基本窗口句柄.
这是我的第二次尝试:
String baseWin = driver.getWindowHandle();
System.out.println(baseWin);
ArrayList<String> popUpWin = new ArrayList<String>(driver.getWindowHandles());
popUpWin.remove(baseWin);
driver.switchTo().window(popUpWin.get(0));
System.out.println(driver.switchTo().window(popUpWin.get(0)));
Run Code Online (Sandbox Code Playgroud)
此尝试返回一个错误,该错误表示数组popUpWin为空,即size == 0.因此,当我调用driver.getWindowHandles()并且仅包含基本窗口的句柄时,不会检索弹出窗口的句柄.这是IE问题吗?有解决方法吗?或者我在代码中忽略了什么?(请注意,我忽略了我在此处包含的代码中的暂停,所以我不相信这是问题.)
我想在用户在我的应用程序中按顺序(按下按钮)时显示弹出窗口或提示,以确认产品的数量和价格.我怎样才能做到这一点??有人说用AlerDialog,但我不确定.此警报将有两个按钮:"确认"和"取消".
谢谢你的推荐.
我正在尝试为弹出模块提供一个单独的URL,我正在使用一个按钮来重定向:
trigger={ <Link href="/exercisesadd">
<Button style={style} waves='light' > Add new</Button></Link>
}>
Run Code Online (Sandbox Code Playgroud)
但我收到404错误,即使我在反应路由器中有这条路线:
export default () => {
return <Route path="/"component={Container} auth={auth}>
<IndexRoute component={Home}/>
<Route path="/portfolio" onEnter={requireAuth} component={Portfolio} />
<Route path="/Login" component={Home} />
<Route path="/home" component={Home} />
<Route path="/edit" component={Edits}/>
<Route path="/exercises" component={Exercises}/>
<Route path="/exercisesadd" component={Exercises}/>
</Route>
};
Run Code Online (Sandbox Code Playgroud)