标签: button

16
推荐指数
3
解决办法
7476
查看次数

Android:ImageView getID(); 返回整数

我已经设置了一个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很新.如果你们能帮助我,请告诉我.

android button imageview ontouchlistener

16
推荐指数
3
解决办法
4万
查看次数

16
推荐指数
3
解决办法
3万
查看次数

图像按钮仅在单击图像时响应,而不响应按钮内部的区域

我正在使用以下按钮样式,它消除了边框并使透明背景形成我的图像按钮:

  <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)

问题:如何使整个按钮区域对点击作出反应?我想让它保持透明,没有现在的边框.

wpf user-controls styles button wpf-controls

16
推荐指数
2
解决办法
8684
查看次数

多个UIAlertView; 每个都有自己的按钮和动作

我在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)

谢谢你的帮助!

xcode button uialertview ibaction

16
推荐指数
2
解决办法
2万
查看次数

按钮如何获得焦点?

有很多帖子涉及这个话题.我想我应该问这个简单的问题,希望澄清一下.

我无法将焦点设置在按钮上.我知道我可能会错过一些基本的东西 这是简单的布局:

<?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)

它根本不起作用(即按钮没有得到焦点).

任何纠正我的错误或误解将不胜感激.

android button

16
推荐指数
1
解决办法
3万
查看次数

隐藏在XCode 4中的运行/停止按钮

我无法在Xcode 4中看到全屏模式之外的运行和停止按钮.有谁知道如何摆脱这种观点?

这是浪费我的时间是荒谬的.我应该从未升级过.

xcode view button

16
推荐指数
1
解决办法
8158
查看次数

带下拉列表和箭头的WPF按钮

有人可以建议使用带有箭头和下拉列表的按钮的最佳方法,例如在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)

wpf button

16
推荐指数
3
解决办法
4万
查看次数

锚标记未使用twitter bootstrap显示为按钮

我正在使用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)

它按预期显示

在此输入图像描述

anchor button twitter-bootstrap

16
推荐指数
1
解决办法
3万
查看次数

Flutter onTap方法的容器

正在开发一个扑腾的应用程序,并从一些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)

user-interface button dart flutter

16
推荐指数
5
解决办法
2万
查看次数