我创建了一个按钮,它应该支持自动换行。我的按钮 XAML 代码如下所示:
<Button x:Class="POS.TouchScreen.UI.Elements.TouchButtonWPF"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" Height="23" HorizontalAlignment="Left" Name="buttonGrid" VerticalAlignment="Top" Width="75" BorderBrush="#FF8A97A9" Margin="4"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<TextBlock Name="ButtonTextBlock"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Text="{Binding ButtonText, Mode=TwoWay}"
TextWrapping="Wrap">
</TextBlock>
</Button>
Run Code Online (Sandbox Code Playgroud)
我已经实现了该属性,如下所示:
public static readonly DependencyProperty ButtonTextProperty =
DependencyProperty.Register("ButtonText", typeof(string), typeof(TouchButtonWPF), new UIPropertyMetadata("Button",new PropertyChangedCallback(OnButtonTextChanged), new CoerceValueCallback(OnCoerceButtonText)));
private static object OnCoerceButtonText(DependencyObject o, object value)
{
TouchButtonWPF button = o as TouchButtonWPF;
if (button != null)
return button.OnCoerceButtonText((string)value);
else
return value;
}
protected virtual string OnCoerceButtonText(string value)
{
return value;
}
private static …Run Code Online (Sandbox Code Playgroud) 我想将图像设置为 Windows 窗体按钮的背景。
\n\n该图像将添加到project\xc2\xb4s 资源中。
\n\n我该怎么做呢?
\n我必须制作一个使用唤醒锁保持屏幕打开的应用程序。我有两个按钮,一个用于打开唤醒锁,一个用于关闭它。
打开唤醒锁的按钮工作正常,但关闭唤醒锁的按钮会导致应用程序崩溃。
这是代码:
public class MainActivity extends ActionBarActivity {
@Override @SuppressWarnings("deprecation")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupScreenONButton();
setupScreenOFFButton();
}
@SuppressWarnings("deprecation")
private void setupScreenOFFButton() {
Button ScreenOffButton = (Button) findViewById(R.id.buttonScreenOFF);
ScreenOffButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,"Screen OFF");
wl.release();
Toast.makeText(MainActivity.this, "Screen OFF", Toast.LENGTH_SHORT).show();
}
});
}
@SuppressWarnings("deprecation")
private void setupScreenONButton() {
Button ScreenOnButton = (Button) findViewById(R.id.buttonScreenON);
ScreenOnButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
PowerManager pm = …Run Code Online (Sandbox Code Playgroud) 我正在尝试向框架 gui 添加一个按钮。
我尝试制作一个面板并将其添加到其中,但它不起作用。请帮忙!
这是我的代码:
import javax.swing.*;
public class Agui extends JFrame {
public Agui() {
setTitle("My Gui");
setSize(400, 400);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JButton button;
JPanel panel;
// my error lines are under the "panel" and "button"
// it says i must implement the variables. what does that mean???
panel.add(button);
}
public static void main(String[] args) {
Agui a = new Agui();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个包含几个按钮的窗口(该窗口充当起始页)。当我第一次创建并打开 时Shell,第一个Button创建的将被分配焦点。有没有办法消除这个焦点Button?
使用SWT.NO_FOCUS没有帮助。
因此,我正在尝试一种新型按钮,使用我现在找不到的教程......最终产品可以工作,但按钮上的可点击区域非常令人沮丧,很小。我尝试编辑 css,因为我认为这只是一个 css 问题,但我无法让它工作。由于可点击区域较小,它似乎无法在移动设备上运行。
有问题的网站是http://forrestburdette.com/ 有问题的按钮是其儿童外展部的右上角按钮。它似乎只能在按钮的最右中间点击。我需要一些关于我哪里出错了的指导!希望这是一个简单的修复!
我已经做了研究,但还没有找到解决我的问题的方法。有什么好方法可以禁用 Win32 中的最小化、最大化和关闭按钮吗?我希望他们仍然存在并充满活力,但不敏感。我还希望能够通过拖动框架来调整窗口大小。
我想创建一个按钮,单击该按钮时,它将显示另一个意图。
这是代码:
<Button
android:text="Bine ati venit!"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/button1"
android:background="#479fc7"
android:textSize="40dp"
android:textColor="@color/colorPrimaryDark"
android:textStyle="normal|bold|italic"
android:textAllCaps="false"
android:fontFamily="casual"
android:onClick="next_page"/>
Run Code Online (Sandbox Code Playgroud)
以及来自 .java 类:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
}
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener( new View.OnClickListener()
{
public void onClick (View v){
next_page(v);
}
});
public void next_page(View v) {
Intent intent = new Intent(this, MapsActivity.class);
startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:“无法解析符号‘setOnClickListener’”、“变量 onClick 从未使用”、“;预期”...
我有几个工作正常的验证函数,我想用简单的 javascript(没有 jQuery 等)为整个表单编写一个附加验证,根据其他验证函数返回 true 还是 false 来禁用/启用“提交”按钮。我该怎么办?
例如,对于我的主要 HTML,我有:
<form id="form" method="POST">
<label class="form">Field 1</label><input type="text" name="input1" onkeyup="validateInput1(); return false">
<label class="form">Field 2</label><input type="text" name="input2" onkeyup="validateInput2(); return false">
...
<button id="submit" type="submit" value="submit">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
对于我的脚本,我有:
function validateInput1(){
...
}
function validateInput2(){
...
}
Run Code Online (Sandbox Code Playgroud)
现在我想编写一个类似以下内容的函数:
function validateForm(){
var submitButton = document.getElementById('submit');
submitButton.disabled = true;
/*If all other validation functions like validateInput1() returns true then submitButton.disabled = false*/
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
我正在使用 jQuery,想知道用户在输入字段中输入内容后如何启用按钮?如果他们删除了输入字段的内容,则该按钮将再次被禁用。我创建了这个小演示来提供帮助。
我必须使用“keyup”来执行此操作吗?
$( "#target" ).keyup(function() {
alert( "Handler for .keyup() called." );
});
Run Code Online (Sandbox Code Playgroud)