我想在用户单击按钮时启动服务。
基本上,当用户单击开始按钮时,服务应开始记录 GPS 坐标,当他单击停止时,服务应终止。
我应该如何实施这个?
我在 java 代码中创建了按钮,但无法更改按钮的大小。我使用了
btn = new Button(Activity.this);
btn.setText("\t\t" + lbl + "\t\t\t ");
btn.setBackgroundResource(R.drawable.blue_button);
btn.setwidth(100);
Run Code Online (Sandbox Code Playgroud)
但没有用。知道吗?谢谢

我想在按钮的中心添加一个图像(用户图像)并保持按钮的背景颜色(灰色)。
我尝试将背景属性与填充一起使用,但似乎没有效果。
任何人都可以指导我怎么做吗?
我应该在我的 xml 中使用drawableTop等属性吗???
请帮忙。
标题已经描述了我的问题。我想为 JFX 按钮中的单个字母或字母序列而不是整个文本着色。我找到了 Swing 组件的解决方案是否可以在 Java 中将字符串中的文本颜色更改为多种颜色?但还不适用于 javafx。任何人都可以帮助我吗?
我有一个按钮,它有一个透明的背景和一个厚厚的白色边框。当按钮检测到鼠标进入时,我看到背景从设置的透明背景变为默认聚焦颜色,因此我将不透明度设置为 0.2,以便它显示一些反馈,表明它具有焦点。
现在这是我的困境。当我离开按钮的边界时,在将背景更改为原始透明之前,有一个小动画从我的 .2 不透明度变为 1。我想知道如何用更平滑的动画替换它,以便在它变为透明之前我看不到不透明的背景,或者只是有办法完全绕过动画并让它设置我的值。当按钮聚焦时,我看到类似的事情发生。它将使用默认背景颜色在 0.2 不透明度和 1.0 之间设置动画。任何想法将不胜感激。
<Button BorderBrush="White" BorderThickness="1" Width="45" Height="45" >
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.2" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Opacity" Value="1.0" />
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
Run Code Online (Sandbox Code Playgroud) 我正在使用 VS 2008。在 Windows 或智能设备项目中,当按钮当前具有焦点时按空格键将导致单击该按钮并引发Click事件。是否有任何属性或设置会导致它跳过它,以便空格键不会导致按钮单击?
我不知道我的问题究竟出在哪里,要么是绑定,要么是函数本身被调用。
我的按钮都出现在一个labelFrame下,每个按钮都带有一个输入框,这样用户可以加载许多csv文件进行分析,并且文件路径是可见的。用户必须搜索它,因为这些文件可能存在于我不同且未连接的项目文件夹中。
这是一个示例按钮。
csv_type21 = Button(csvfiles, text = "Browse ...")
csv_type21.bind("<Button-1>", lambda event, obj = var21, tid = 21: find_cvsfile(event, obj, tid))
Run Code Online (Sandbox Code Playgroud)
如果用户取消查找文件,它们会保持沉没,即使他们选择了一个文件,它也会保持沉没。(但输入框确实使用文件路径更新)。
这是他们调用的函数,它要求一个 csv 文件并将其保存为一个元组,以便我可以跟踪哪个 csv 是哪个。之后,我为按钮所对应的 Entry 框设置 StringVar 以说明文件路径。
def find_csvfile(event, obj, tid):
input_csvfile = askopenfile(initialdir = 'C:/',
filetypes = [("CSV File", "*.csv")],
title = 'Open CSV File for id ' + str(tid) + '...',
mode = 'r')
csv_data = tid, input_csvfile
filepath = input_csvfile.name
obj.set(filepath)
Run Code Online (Sandbox Code Playgroud)
我试过摆弄大量不同的变量和参数,但没有任何效果。我认为它必须是调用相同命令的多个按钮,但我不能确定。
任何帮助表示赞赏。
谢谢。
请有人帮忙。我正在尝试在 javascript 中创建一个基本按钮,当单击它时,它会从我的数组中随机选取一个值并将其显示在屏幕上,每次单击该按钮时,它都应该从数组中选取一个新项目。我知道如何写数组
var myarray = new Array("item1", "item2", "item3");
Run Code Online (Sandbox Code Playgroud)
我只是不知道如何做按钮部分。任何帮助都会很棒。我知道在 jQuery 中执行此操作可能更容易,但我真的很想在处理 jQuery 之前先了解一下 javascript(请保持温和,我是这个哈哈的新手)
当键盘可见时,我有一个表单和下面的按钮应该可见,但我不知何故无法管理该状态。
在活动清单中,我有:
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"
android:configChanges="orientation"
Run Code Online (Sandbox Code Playgroud)xml 文件看起来像这样。
<com.myapp.components.NonInvasiveScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:fadingEdgeLength="0dp"
android:paddingBottom="10dp"
android:orientation="vertical" >
<HorizontalScrollView
android:id="@+id/hor_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fadingEdgeLength="0dp"
android:scrollbars="none"
android:overScrollMode="never"
android:paddingTop="15dp"
>
<ImageView
android:id="@+id/vizual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/vizual"
/>
</HorizontalScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="5dp" >
<RadioGroup
android:id="@+id/add_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/add_fragment_margin"
android:layout_marginRight="@dimen/add_fragment_margin"
android:orientation="horizontal"
android:weightSum="2" >
<com.funtasty.appool.components.SegmentedControlButton
android:id="@+id/mam_napad"
android:layout_width="0dp"
android:layout_weight="1"
android:checked="true"
android:text="Mám nápad na aplikaci"
android:singleLine="true"
android:textSize="@dimen/smallText" />
<com.myapp.components.SegmentedControlButton
android:id="@+id/umim_tvorit"
android:layout_width="0dp"
android:layout_weight="1"
android:checked="false"
android:singleLine="true"
android:text="Umím tvo?it aplikace"
android:textSize="@dimen/smallText" />
</RadioGroup>
<ViewFlipper
android:id="@+id/viewFlipper"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud)我正在使用 matplotlib 运行动画FuncAnimation以显示来自微处理器的数据(实时)。我正在使用按钮向处理器发送命令,并希望按钮的颜色在被点击后改变,但我在matplotlib.widgets.button文档中(目前)找不到任何可以实现这一点的内容。
class Command:
def motor(self, event):
SERIAL['Serial'].write(' ')
plt.draw()
write = Command()
bmotor = Button(axmotor, 'Motor', color = '0.85', hovercolor = 'g')
bmotor.on_clicked(write.motor) #Change Button Color Here
Run Code Online (Sandbox Code Playgroud)