我正在尝试在执行下载任务时禁用按钮.我尝试过使用setEnabled,setVisibility和setClickable.我想我尝试了这些选项的所有组合.所有这些都在任务执行时禁用了按钮单击事件,但事件仍在某种程度上被注册,当我响应按钮时,如果我在禁用时单击按钮,则会调用处理程序...即使它是看不见或"走了"!(不确定它是否被称为处理程序,我想引用onClick方法).
我还插入了一个计数器和一个Log来验证我上面说过的内容.代码如下所示.这段代码if(counter>1) return;旨在阻止崩溃,但我想删除它,因为我想重新启用按钮,而不是永远禁用它.
的onClick:
public void downloadOnClick(View v) {
counter++;
Log.d(this.getLocalClassName(), "Button was clicked " + counter + " times.");
if(counter>1) return;
ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
//mButton.setVisibility(View.GONE);
mButton.setEnabled(false);
//mButton.setClickable(false);
mTextView.setText("Getting html file...");
// if we use simple http, we will need to handle redirect status code
new DownloadWebpageTask().execute("https://www.google.com/");
} else {
mTextView.setText("No network connection available.");
}
}
Run Code Online (Sandbox Code Playgroud)
的AsyncTask:
private class DownloadWebpageTask extends AsyncTask<String, Void, String> { …Run Code Online (Sandbox Code Playgroud) 我正在创建一个Python(3.4.3) - tkinter程序,我想知道是否可以def从另一个内部引用(self.get_details)class按钮的命令.我无法在任何地方找到这个问题的答案,所以我想我只是问.
例:
import tkinter as tk
...
class Widgets(tk.Frame):
def __init__(self, parent):
tk.Frame.__init___(self, parent)
self.parent = parent
self.initUI()
def initUI():
# Lots of other different tkinter widgets go here
self.button = tk.Button(command=App(get_details))
self.button.pack()
class PopUp(tk.TopLevel): ....
class App(tk.Frame):
def __init__(self, parent):
tk.Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def get_details(self):
# Complete a function
def initUI(self):
self.parent.title("My Application")
self.style = Style()
self.style.theme_use("default")
self.pack()
self.widgets = Widgets(self)
self.widgets.pack(side="top", anchor="center", fill="both", expand=True)
if __name__ == "__main__":
root …Run Code Online (Sandbox Code Playgroud) 我需要在同一页面上的两个(或更多)fullcalendars之间切换,并希望将此功能添加到日历标题内的自定义按钮.
我在自定义按钮上发现了一些有趣的代码,但它有点过时,因为它引用了Fullcalendar v 1.6.1并且我使用的是2.3.1.
这是我发现的:http://code.google.com/p/fullcalendar/issues/detail?id = 225#c17及更高版本.我几乎成功实现了这一点:http://code.google.com/p/fullcalendar/issues/detail?id = 225#c24但是脚本被重写并且与此代码不匹配.
任何拥有与2.3.1一起使用的自定义按钮的更新代码的人?
当我为我的工厂设置颜色时,它看起来像这样:

我的布局xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity$PlaceholderFragment">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add"
android:layout_marginRight="20dp"
app:fabSize="normal"
android:elevation="@dimen/fab_elevation"
android:background="#000000"
android:stateListAnimator="@animator/fab_anim"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
Run Code Online (Sandbox Code Playgroud)
颜色也不会改变.谁能帮我理解我做错了什么?
我也尝试了一个@color链接,但它崩溃了,一个drawable的背景(ex. android:background="@drawable/fab_background")没有任何反应.
这是可绘制的 fab_background.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<ripple android:color="@color/fab_color_1_muted">
<item>
<shape>
<solid android:color="@color/fab_color_1" />
</shape>
</item>
</ripple>
</item>
Run Code Online (Sandbox Code Playgroud)
我需要在单页面应用程序中禁用浏览器的后退按钮.我尝试使用像onhashchange或window.history.forward这样的方法,但它们不起作用(原因可能是这里的url没有改变)请帮忙!谢谢.
我是Yii2中的新手,我无法在Yii2中找到后退按钮,我发现Yii1中的解决方案是:
echo CHtml::link('Back',Yii::app()->request->urlReferrer);
Run Code Online (Sandbox Code Playgroud)
但是我无法在Yii2中找到解决方案,你能帮助我吗?
我正在尝试将我的iPhone制作一个基本的应用程序.我是Xcode的新手,我在google上浏览过,无法找到我正在寻找的内容.我正试图为我的飞机制作一份清单.
我基本上有一个带有几个按钮的View控制器.我想要的是按钮在按下后从灰色变为蓝色并保持蓝色,除非再次按下.我根本不了解Xcode和Swift语言,所以如果有人可以提供帮助,请解释好像你正在向孩子解释.
到目前为止,我已经设法让页面全部设置和滚动工作,但我只需要按钮即可更改.
Ty先生,谢谢你.
这是我的按钮:
<Button
Name="btnOk"
Content="OK"
Style="{StaticResource AccentedSquareButtonStyle}"/>
Run Code Online (Sandbox Code Playgroud)
并且content在使用它时总是使用小写Style
我正在尝试向Excel工作簿添加一个按钮,以便它显示在每个工作表中.我原来问题的一个很好的答案给了我一个宏来创建每张纸上的按钮:
Sub AddButtons()
Dim ws As Excel.Worksheet
Dim btn As Button
For Each ws In ThisWorkbook.Worksheets
Set btn = ws.Buttons.Add(X, Y, W, H)
[set btn properties]
Next ws
End Sub
Run Code Online (Sandbox Code Playgroud)
我现在在设置按钮属性时遇到问题,以便按下按钮时按钮打印.这里是我的打印宏:
Dim WS_Count As Integer
Dim i As Integer
' Set WS_Count equal to the number of worksheets in the active workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
'allows user to set printer they want to use
Application.Dialogs(xlDialogPrinterSetup).Show
' Begin the loop.
For i = 5 To WS_Count
Worksheets(i).Activate
With ActiveWorkbook.Worksheets(i).PageSetup
.PrintArea = …Run Code Online (Sandbox Code Playgroud) 我在cellForRowAtIndexPath中有这个
cell.plusBut.tag = indexPath.row
cell.plusBut.addTarget(self, action: "plusHit:", forControlEvents: UIControlEvents.TouchUpInside)
Run Code Online (Sandbox Code Playgroud)
而这个功能在外面:
func plusHit(sender: UIButton!){
buildings[sender.tag].something = somethingElse
}
Run Code Online (Sandbox Code Playgroud)
是否有可能发送indexPath.row 和 indexPath.section,或某些替代?
谢谢!
编辑
我这样接近它:
我的自定义按钮
class MyButton: UIButton{
var myRow: Int = 0
var mySection: Int = 0
}
Run Code Online (Sandbox Code Playgroud)
我的自定义细胞
class NewsCell: UITableViewCell{
@IBOutlet weak var greenLike: MyButton!
Run Code Online (Sandbox Code Playgroud)
在CellForRowAtIndexPath中
cell.greenLike.myRow = indexPath.row
Run Code Online (Sandbox Code Playgroud)
我在这一行上收到错误.