我正在开发一个应用程序,当按下按钮时,它会打开一个带有确定和取消按钮的对话框.
它工作正常.
当用户按下后退按钮时,我按如下方式处理
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK))
{
}
return super.onKeyDown(keyCode, event);
}
Run Code Online (Sandbox Code Playgroud)
但是没有调用上面的方法.我怎么处理这个?
我试图创建按钮并插入我自己的图像而不是标准按钮图像.但是,标准按钮的灰色边框仍然保留,显示在我的黑色按钮图像的外部.
有谁知道如何从按钮中删除这个灰色边框,所以它只是图像本身?谢谢.
无论使用何种浏览器,我都试图将HTML按钮完全对齐在页面的中心.它可以浮动到左边,同时仍然位于垂直中心,或者位于页面上的某个位置,如页面顶部等.
我希望它可以垂直和水平居中.这是我现在写的:
<button type="button" style="background-color:yellow;margin-left:auto;margin-right:auto;display:block;margin-top:22%;margin-bottom:0%">
mybuttonname
</button>
Run Code Online (Sandbox Code Playgroud) 我试图将一个额外的参数传递给buttonClicked操作,但无法确定Swift中的语法应该是什么.
button.addTarget(self, action: "buttonClicked:", forControlEvents: UIControlEvents.TouchUpInside)
Run Code Online (Sandbox Code Playgroud)
任何我的buttonClicked方法:
func buttonClicked(sender:UIButton)
{
println("hello")
}
Run Code Online (Sandbox Code Playgroud)
任何想法?
谢谢你的帮助.
我必须OK在视图中的Click of Button 上打开一个URL .有人可以告诉你怎么做吗?
在Android的设计指南说,使用无边框按钮(见下图),但真的不解释如何.几个星期前有人问过同样的问题:如何创建标准的无边框按钮(如提到的设计指南)?并且有一个答案标记为"答案",但我仍然迷失了,我没有办法在一个已经"关闭"的问题上添加评论
答案者说
"看入主题属性
buttonBarStyle,buttonBarButtonStyle以及borderlessButtonStyle"
但我仍然无法弄清楚如何实际使用这些东西.我用Google搜索了一下,找不到任何东西,所以我想我只是再问这个问题,希望有人可以提供一些更详细的信息.

我有一个带有按钮的tableview,我想在使用其中一个时使用indexpath.row.这是我现在拥有的,但总是0
var point = Int()
func buttonPressed(sender: AnyObject) {
let pointInTable: CGPoint = sender.convertPoint(sender.bounds.origin, toView: self.tableView)
let cellIndexPath = self.tableView.indexPathForRowAtPoint(pointInTable)
println(cellIndexPath)
point = cellIndexPath!.row
println(point)
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用选择器创建一个按钮,我的按钮可以具有以下状态:
根据上述状态.我需要操纵按钮:
该按钮从我被禁用开始,因此它应该具有禁用的textColor和禁用的按钮背景.但我可以看到默认的textColor(在样式中指定)和没有背景图像!
这是我的选择器button_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false"
android:state_enabled="false"
android:textColor="#9D9FA2"
android:drawable="@drawable/button" />
<item android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/button_pressed"/>
<item android:state_pressed="true"
android:state_enabled="false"
android:textColor="#9D9FA2"
android:drawable="@drawable/button"/>
<item android:state_pressed="false"
android:state_enabled="true"
android:drawable="@drawable/button"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
这是我的layout.xml中的按钮声明
<Button android:id="@+id/reserve_button"
android:text="@string/reserve_button"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:paddingRight="15dp"
android:layout_gravity="left"
style="@style/buttonStyle"
android:background="@drawable/button_selector" />
Run Code Online (Sandbox Code Playgroud)
最后这是我的风格(我的默认textColor设置)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="buttonStyle">
<item name="android:textStyle">bold</item>
<item name="android:textColor">#282780</item>
<item name="android:textSize">18sp</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
请帮忙!
我正在尝试在我的onClick(View v)XML中调用该方法,但不能与Fragment一起使用.这是错误.
01-17 12:38:36.840: E/AndroidRuntime(4171): java.lang.IllegalStateException:
Could not find a method insertIntoDb(View) in the activity class main.MainActivity
for onClick handler on view class android.widget.Button with id 'btn_conferma'
Run Code Online (Sandbox Code Playgroud)
MainActivity.java
public void insertIntoDb(View v) {
...
}
Run Code Online (Sandbox Code Playgroud)
xml代码
<Button
android:id="@id/btn_conferma"
style="?android:attr/borderlessButtonStyle"
android:layout_width="0.0dip"
android:layout_height="45dp"
android:layout_marginLeft="2dp"
android:layout_weight="1.0"
android:background="@drawable/bottoni"
android:gravity="center_horizontal|center_vertical"
android:onClick="insertIntoDb"
android:text="SALVA"
android:textColor="#ffffff"
android:textSize="16sp" />
Run Code Online (Sandbox Code Playgroud)