而不是
<input type="submit" />
Run Code Online (Sandbox Code Playgroud)
我想输出
<button>
Run Code Online (Sandbox Code Playgroud)
使用button_to方法(rails 3.0.0)
这可能吗?
我已经设置了一个onTouch类来确定何时按下了我的40个按钮之一.
我面临的问题是确定按下了哪个按钮.
如果我使用:
int ID = iv.getId();
当我点击"widgetA1"按钮时
我收到以下ID:
2131099684
我希望它返回字符串ID"widgetA1"
来自:game.xml
<ImageView android:layout_margin="1dip" android:id="@+id/widgetA1" android:src="@drawable/image" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
Run Code Online (Sandbox Code Playgroud)
来自:game.java
public boolean onTouch(View v, MotionEvent event) {
ImageView iv = (ImageView)v;
int ID = iv.getId();
String strID = new Integer(ID).toString();
Log.d(TAG,strID);
//.... etc
}
Run Code Online (Sandbox Code Playgroud)
+ - + - + - + - + - + -
我其他明智的工作正常,它知道你按什么按钮.我对这个Android JAVA很新.如果你们能帮助我,请告诉我.
我正在使用以下按钮样式,它消除了边框并使透明背景形成我的图像按钮:
<Style x:Key="EmptyButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Background" Value="#00000000"/>
<Setter Property="BorderBrush" Value="#00000000"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
样式来自以下答案: 带有圆形图像的WPF按钮
现在的问题是无论实际按钮有多大,可点击区域都被限制在图像中:

我的按钮代码:
<Button Name="n02" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Style="{DynamicResource EmptyButtonStyle}" Canvas.Left="308" Canvas.Top="157" Height="106" Width="120">
<Image Source="boto_face_off.PNG" Height="61" Width="59" />
</Button>
Run Code Online (Sandbox Code Playgroud)
问题:如何使整个按钮区域对点击作出反应?我想让它保持透明,没有现在的边框.
我在Xcode 4.3中创建一个视图,我不确定如何指定多个UIAlertView,它们有自己的按钮和单独的动作.目前,我的警报有自己的按钮,但操作相同.以下是我的代码.
-(IBAction)altdev {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"titleGoesHere"
message:@"messageGoesHere"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Continue", nil];
[alert show];
}
-(IBAction)donate {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"titleGoesHere"
message:@"messageGoesHere"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Continue", nil];
[alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.examplesite1.com"]];
}
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"examplesite2.com"]];
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
有很多帖子涉及这个话题.我想我应该问这个简单的问题,希望澄清一下.
我无法将焦点设置在按钮上.我知道我可能会错过一些基本的东西 这是简单的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:focusable="true" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
以下是onCreate()中的简单代码:
Button button = (Button)findViewById(R.id.button1);
button.setFocusable(true);
button.requestFocus();
button.setText("Debug"); //Just to show the code here has been executed
Run Code Online (Sandbox Code Playgroud)
它根本不起作用(即按钮没有得到焦点).
任何纠正我的错误或误解将不胜感激.
我无法在Xcode 4中看到全屏模式之外的运行和停止按钮.有谁知道如何摆脱这种观点?
这是浪费我的时间是荒谬的.我应该从未升级过.
有人可以建议使用带有箭头和下拉列表的按钮的最佳方法,例如在visual studio工具栏按钮新项目中.正如您在VS中所见,鼠标悬停突出显示默认按钮和箭头按钮,从列表中选择项目后,默认按钮将根据您的选择进行更改.

这是一段显示下拉菜单的代码,但不是上面描述的完整功能:
<StackPanel Orientation="Horizontal">
<Border CornerRadius="0" BorderBrush="Black" BorderThickness="1">
<Button Name="CreateButton" Click="CreateButton_Click" Background="Transparent" BorderBrush="{x:Null}">
<Image Source="/OMS.Resources;component/Resources/Images/LibraryImages/add1.png" />
<Button.ContextMenu>
<ContextMenu HorizontalAlignment="Right">
<MenuItem Header=" doc" Click="CreateDocButton_Click">
<MenuItem.Icon>
<Image Source="/OMS.Resources;component/Resources/Images/LibraryImages/add_sheet.png" Width="24" Height="24" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header=" xls" Click="CreateXlsButton_Click">
<MenuItem.Icon>
<Image Source="/OMS.Resources;component/Resources/Images/LibraryImages/add_sheet.png" Width="24" Height="24" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header=" txt" Click="CreateTxtButton_Click">
<MenuItem.Icon>
<Image Source="/OMS.Resources;component/Resources/Images/LibraryImages/add_sheet.png" Width="24" Height="24" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</Button.ContextMenu>
</Button>
</Border>
<Border CornerRadius="0" BorderBrush="Black" BorderThickness="1">
<Button HorizontalAlignment="Left" VerticalAlignment="Stretch" Background="Transparent" BorderBrush="{x:Null}"
ContextMenuService.IsEnabled="False" Click="AddButtonContextMenu_Click">
<Image Source="/OMS.Resources;component/Resources/Images/LibraryImages/arrow_down.png" VerticalAlignment="Center" Width="9" />
</Button>
</Border>
</StackPanel>
Run Code Online (Sandbox Code Playgroud) 我正在使用twitter bootstrap 3.0并试图将锚标签显示为按钮使用
<a href="#" class="btn">Add button</a>
Run Code Online (Sandbox Code Playgroud)
但它没有显示为按钮

我用的时候
<button class="btn"> Add button</button>
Run Code Online (Sandbox Code Playgroud)
它按预期显示

正在开发一个扑腾的应用程序,并从一些Firebase数据动态构建一些容器.我想知道是否有办法为容器(或任何不是按钮的小部件)获取onTap方法?
这是一个代码示例:
child: new Container(
//INSERT ONTAP OR ONPRESSED METHOD HERE
margin: const EdgeInsets.symmetric(vertical: 10.0),
child: new Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Container(
margin: const EdgeInsets.only(right: 16.0),
child: new GoogleUserCircleAvatar(snapshot.value['images'][0]),
),
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children : [
new Container(
padding: const EdgeInsets.only(bottom: 8.0),
child: new Text("${snapshot.value['name']}",
style: new TextStyle(
fontWeight: FontWeight.bold,
),
),
),
new Text("${snapshot.value['description']}",
style: new TextStyle(
color: Colors.grey[500],
),
),
]
)
],
),
Run Code Online (Sandbox Code Playgroud)