下面是一个 IBAction 的代码,我想在点击它后禁用 5 秒。
@IBAction func postPressed(sender: AnyObject) {
//var disableMyButton = sender as? UIButton
//disableMyButton!.enabled = false
//NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector:"enableButton", userInfo: nil, repeats: false)
if(currLocation != nil){
let testObject = PFObject(className: "Hey")
testObject["text"] = self.postView.text
testObject["count"] = 0
testObject["replies"] = 0
testObject["location"] = PFGeoPoint(latitude: currLocation!.latitude , longitude: currLocation!.longitude)
testObject["comments"] = []
testObject["user"] = PFUser.currentUser()
testObject.saveInBackgroundWithBlock({ (success, error) -> Void in
if success {
self.dismissViewControllerAnimated(true , completion: nil)
if let completion = self.completion {
completion(self)
}
}
}) …Run Code Online (Sandbox Code Playgroud) 我有一个本地开发的 Bootstrap 站点,如果您调整浏览器窗口的大小,导航栏可以在桌面上的每个大小(低至 320 像素宽)下完美运行。但是,如果您使用浏览器的设备模拟,或查看实际手机上的页面,“汉堡包”菜单按钮会向右移出屏幕,您必须向右滚动才能看到它。我整个下午都在谷歌上搜索和调整我能想到的每一种风格,没有任何改变。我希望其他人遇到过这个问题。
三个注意事项:(1) 一些菜单样式(特别是左侧定位)可能看起来/很奇怪,但需要将菜单在屏幕上保持在非常窄的宽度。删除该定位无济于事。(2) 我有一个拆分标题,我在其中为左右指定 XS-6 - 从技术上讲,我认为所有行都应该是移动 XS 大小的完整 12 列宽度,但再次......改变这个根本没有改变问题——它只是在第二行离开了屏幕。(3) 这是一个 wordpress 站点,我使用的是 wp_bootstrap_navwalker。
这是我的 HTML 和 CSS... 建议?
.container{width:auto;}
.navbar-default .navbar-toggle {border-color:#4B4F5B;padding:5px;margin-top:23px;margin-right:10px;}
.navbar-default .navbar-toggle .icon-bar{background-color:#4B4F5B;}
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus {background-color:#fff;}
.navbar-collapse {border-top:1px dotted #4B4F5B;position:relative;left:-10px;}
.navbar-collapse.in {overflow-y: visible;} /*show overflow to avoid submenu scrolling*/
#menu-menu1 {position:relative;left:-35px;}
.dropdown-menu {position:relative;left:-70px;}
#header_left {margin:0;padding:0;}
#header_right {margin:0;padding:0;}Run Code Online (Sandbox Code Playgroud)
<!-- HEADER / NAV -->
<header class="row navrow">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<!-- LEFT SIDE -->
<div class="col-xs-8 …Run Code Online (Sandbox Code Playgroud)我有一个列表视图,它显示项目名称和每个项目的一些按钮,这些按钮执行不同的操作,例如为该项目添加评论查看图像等。根据项目的不同,某些项目有时会禁用其中一些按钮。并且某些按钮在某些项目中将不可见。所以我想在这段代码中使用数据绑定来实现两件事。
根据 ProjectModel 的一些布尔变量,我需要更改按钮的可见性。我尝试将按钮的可见性绑定到 ViewModel 中的 bool 值,但它似乎不适用于 uwp。
对于某些项目,当禁用该选项时,我需要显示不同的彩色图像。所以我需要根据 ProjectModel 的布尔变量更改 ImageBrush 的 ImageSource。为此,我使用触发器 WPF MVVM尝试了此更改图像,但这些样式触发器不适用于 uwp。
请让我知道如何在 UWP 应用中轻松完成这些操作。这是我的第一个 UWP 应用程序,我对这些概念不熟悉。
<ListView x:Name="stepsListView" Margin="10,0,0,0" RequestedTheme="Dark" FontSize="24" Background="{StaticResource procedure_app_white}" Foreground="Black" BorderThickness="1.5" BorderBrush="Transparent" ItemsSource="{Binding projectList}" HorizontalAlignment="Left">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListView.ItemContainerStyle>
<!-- Item -->
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderThickness="0,0,0,1" BorderBrush="#c0c0c0">
<Grid Width="auto" HorizontalAlignment="Stretch" DataContextChanged="Grid_DataContextChanged" >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/> …Run Code Online (Sandbox Code Playgroud) 我的应用程序中有一些可关闭的视图,标题中有一个关闭按钮。我想让这个按钮无边框和小。
编码:
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/borderlessButtonStyle"
android:layout_margin="0dp"
android:padding="0dp"
android:src="@android:drawable/ic_menu_close_clear_cancel"/>
Run Code Online (Sandbox Code Playgroud)
我只想让我的图像按钮在应用程序启动时在第一个屏幕中执行缩放(反复小放大和缩小)动画,直到我按下它。那是因为这是应用程序的“主要”和最重要的按钮,我想引起用户的注意。我找到了一些教程,并且达到了这个程度:
主屏幕.java
package com.example.konarx.a11042016;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
public class MainScreen extends AppCompatActivity {
private Button btn;
final Animation scale; //ERROR - Variable 'scale' might not have been initialized//
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
final scale = AnimationUtils.loadAnimation(this, R.anim.gps_button_animation); //ERROR - Unknown class: 'scale'//
btn = (Button) findViewById(R.id.ImageButton); //ERROR - Unexpected cast to `Button`: layout tag was `ImageButton`//
btn.startAnimation(scale); //I just want to do the animation without …Run Code Online (Sandbox Code Playgroud) 我正在使用 WPF,我想做的是设置按钮的不透明度和背景颜色,但我不想影响按钮内的内容。我尝试了几种方法,但不幸的是这不起作用。
这是我的数字键盘:(我正在尝试编辑 BTN 7):
正如你们所看到的,不幸的是,我无法在不影响内部内容的情况下设置按钮的不透明度。
这是我的 XAML 代码(关注 btn 7):
<StackPanel Height="50" Orientation="Horizontal" Margin="0,0,0,5">
<Button FontSize="15" FontWeight="Bold" x:Name="btn7" Foreground="#83D744" Click="btn7_Click" BorderBrush="#83D744" BorderThickness="0.5" Content="7" Width="80" RenderTransformOrigin="0.557,0.693" d:LayoutOverrides="HorizontalAlignment" Background="Black" Opacity="0.2" Margin="0,0,5,0" />
<Button FontSize="15" Foreground="Black" FontWeight="Bold" x:Name="btn8" Click="btn8_Click" Content="8" Width="80" Background="#FF50504F" Margin="0,0,5,0"/>
<Button FontSize="15" Foreground="Black" FontWeight="Bold" x:Name="btn9" Click="btn9_Click" Content="9" Width="80" d:LayoutOverrides="HorizontalAlignment" Background="#FF50504F"/>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
所以有人可以帮我请如何解决这个问题..谢谢!
我有一个简单的按钮,我希望它具有“粘性”按钮的行为,例如它在视觉上具有两种状态(很像开关)。换句话说,即使我松开鼠标按钮,我也希望它保持按下的样式,但它必须是可点击的。
有没有办法在 WPF 中轻松做到这一点?我正在使用 Fluent,但如果需要,我可以更改它。
<Fluent:Button Header="myButton" Command="{Binding ToggleCommand}" SizeDefinition="Small">
<Fluent:Button.Icon>
<Grid Width="16" Height="16">
<Image Source="../Images/16x16/icon.png"/>
</Grid>
</Fluent:Button.Icon>
</Fluent:Button>
Run Code Online (Sandbox Code Playgroud)
像这样的东西:
PS:
我正在使用 MVVM,并且在 中Command,我正在检查和更改bool标志以了解按钮当前处于什么状态。如果有任何帮助,我可以将其绑定到按钮属性。
我在 C++ 中创建了一个按钮,如下所示:
HWND btn = CreateWindow(
"BUTTON",
"OK",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
10,
10,
100,
100,
hWnd,
NULL,
(HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),
NULL);
Run Code Online (Sandbox Code Playgroud)
该按钮显示在主窗口 (hWnd) 中,但我不知道如何或在何处为其提供事件处理程序。请问有什么帮助吗?
我创建了一个带边框的按钮:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FFFFFFFF" />
<stroke
android:width="1dp"
android:color="#FFCCCCCC" />
</shape>
Run Code Online (Sandbox Code Playgroud)
和
<Button
android:text="@null"
android:stateListAnimator="@null"
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/colorButton"
android:background="@drawable/button_border" />
Run Code Online (Sandbox Code Playgroud)
现在我以编程方式更改背景的颜色。问题是一旦我更改背景,边框就会被删除。有没有办法改变按钮的背景颜色并保持边框?
默认情况下,Button 中的文本居中,但我希望它向左对齐,因此当我键入的文本多于按钮可以显示的文本时,它不会切断句子/单词的开头。感谢帮助。