Android Builder对话框按钮onClickListener(Android Builder dialog button onClickListener)
早上好家伙,
我正在使用Android中的应用程序,我想使用一个对话框来确认退出应用程序。 我使用以下代码创建构建器:
dialog.setMessage("Are you sure you wish to cancel?") .setTitle("Confirm Cancel") .setNegativeButton("No", this) .setPositiveButton("Yes", this) .show();
我知道可以按如下方式处理
onClickListener
:dialog.setPositiveButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } });
我更喜欢实现
DialogInterface.OnClickListener
,它创建一个onClick(DialogInterface dialog, int which)
方法,我可以处理代码,因为它使代码在我看来更具可读性。如何处理单击的按钮? 我习惯使用
View.OnClickListener
在其中使用if
或者switch
,其中view == "button clicked"
。 请允许任何人为我澄清这一点。 任何帮助,将不胜感激。Good morning guys,
I am working on an application in Android and I want to use a dialog to confirm exit of the application. I create the builder with the following code:
dialog.setMessage("Are you sure you wish to cancel?") .setTitle("Confirm Cancel") .setNegativeButton("No", this) .setPositiveButton("Yes", this) .show();
I am aware that it is possible to handle the
onClickListener
as follows:dialog.setPositiveButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } });
I prefer implementing the
DialogInterface.OnClickListener
which creates aonClick(DialogInterface dialog, int which)
method where I can handle the code as it makes the code more readable in my opinion.How would I handle which button is clicked? I am used to using the
View.OnClickListener
in which you use either anif
or aswitch
whereview == "button clicked"
. Please can anyone clarify this for me. Any help would be appreciated.
原文:https://stackoverflow.com/questions/32645170
最满意答案
使用前导点将您的Cookie域更改为
.example.com
。Change your cookie domain to
.example.com
with a leading dot.
相关问答
更多-
这意味着他在一些php文件的末尾删除了?> 。 但在您的情况下,您只需要从/application/libraries/phpbb_library.php文件中切断BOM It means that he removed ?> in the end of some php file. But in your case all you need is just to cut off the BOM from the /application/libraries/phpbb_library.php file
-
垃圾邮件预防是一个多层次的过程。 我列出的MOD和设置对我有用,但不要以任何方式阻止所有垃圾邮件。 正如你所提到的,似乎有人在幕后注册了一些账户。 这是真的。 之后,该人返回或有自动机器人使用他的凭据发布垃圾邮件。 在那些情况下,你唯一的选择是做出反应。 你将无法阻止一切。 正如评论中提到的,第一步是为第一篇文章设置批准队列。 在PHPBB 3.0.3中,添加了此选项。 浏览到管理控制面板 选择“常规”选项卡 在左侧,在Board Configuration下,选择Post Settings 找到“ Ena ...
-
使用此查询: $sql = "SELECT phpbb_users.user_id, phpbb_user_group.group_id, phpbb_users.username, phpbb_profile_fields_data.pf_country, phpbb_profile_fields_data.pf_class, phpbb_user_group.group_leader FROM phpbb_users, phpbb_profile_fields_data, phpbb_user_grou ...
-
使用: SELECT LAST_INSERT_ID() 参考: LAST_INSERT_ID vai phpbbdoctor.com MySQL文档 Use: SELECT LAST_INSERT_ID() Reference: LAST_INSERT_ID vai phpbbdoctor.com MySQL documentation
-
在代码标签中找到文本是正常的阅读本文 据我所知,phpbb不会将标签中的单词标记为[代码]并可能在其他标签中。 稍后我会尝试在源代码中找到它 It is normal not to find text in code tags Read this As I understand, phpbb does not index words in tags as [code] and probably in other tags. Later I will try find it in source
-
我的假设是您已经可以从PHPBB访问$users对象。 由于系统中的第一个用户是Anonymous (并且PHPBB将其用作来宾帐户 ),因此您可以检查这是否是当前正在使用的用户。 if ($user->data['username'] == 'Anonymous') { echo 'Please login!'; } else { // Your existing code } My assumption is that you already have access to the $u ...
-
编辑:我明白了。 我正在使用phpBB3 3.0.10 SMTP:tls://email-smtp.us-east-1.amazonaws.com(你必须添加tls://前缀!) 港口:465 SMTP的身份验证方法:PLAIN SMTP用户名/密码:使用您在Amazon IAM中配置的用户名/密码。 例如,我的用户名是AKIAJKVKV2TENFEUP6WA,密码更复杂。 根据最初的调查结果,亚马逊短信非常活泼。 在几秒钟内交付。 -Josh EDIT: I figured it out. I'm usi ...
-
自动注销phpBB3(通过jFusion集成到Joomla中)(automatically log out in phpBB3 ( integrated into Joomla via jFusion ))[2022-05-18]
使用前导点将您的Cookie域更改为.example.com 。 Change your cookie domain to .example.com with a leading dot. -
如果您使用的是5.3,那么就有PHP 名称空间 。 There are PHP namespaces, if you're on 5.3.
-
使用nginx和phpbb3论坛并排运行symfony2应用程序(Running a symfony2 app using nginx and phpbb3 forum alongside each other)[2023-12-23]
在nginx中添加/ forum位置 location /forum { root [path to www]/forum; try_files $uri $uri/ [index location]; } 我之前没有使用phbb3,所以我不知道它的确切索引位置。 add the /forum location in nginx location /forum { root [path to www]/forum; try_files $uri $uri/ [index l ...