标签: button

Onlclick监听器无法正常工作..?

我有按钮,我使用旋转动画旋转了45度,并应用于烘焙消息的点击监听器.

当我点击上面50%的按钮吐司显示.但当我点击按钮的低50%时,没有任何东西在发生.

这里有动画代码.

<?xml version="1.0" encoding="utf-8"?>
<rotate
 xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="45"
    android:toDegrees="45"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration="0" android:fillAfter="true">
</rotate>
Run Code Online (Sandbox Code Playgroud)

DF

提前致谢.....!

animation android onclick button

6
推荐指数
1
解决办法
883
查看次数

如何使Android Button的drawableLeft保持旋转?

我需要创建一个按钮,左边有一个图标,右边有一个文本.按下按钮后,我想在按钮左侧图标的位置看到旋转图像的动画.

我知道如何使用ImageView旋转图像,但它对我当前的要求没有帮助.

我试图使用AnimationDrawable,但它也没有用,没有动画但只显示了第一个png文件.无论我使用什么背景或leftDrawable按钮来运行AnimationDrawable都是一样的.代码如下:

package com.example.layout;

import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.Button;

public class TestLinearlayoutActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    public void onStart() {
        super.onStart();

        Button locationTitleButton = (Button) findViewById(R.id.LocationTitleButton);
        //locationTitleButton.setBackgroundResource(R.drawable.loading);

        locationTitleButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.loading, 0, 0, 0);

        Drawable[] locationTitleButtonDrawables = locationTitleButton.getCompoundDrawables();
        AnimationDrawable animDrawable = (AnimationDrawable) locationTitleButtonDrawables[0];
        //AnimationDrawable animDrawable = (AnimationDrawable) locationTitleButton.getBackground();
        animDrawable.start();
    }
}

//loading.xml:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">

    <item …
Run Code Online (Sandbox Code Playgroud)

android rotation button

6
推荐指数
1
解决办法
4479
查看次数

找不到onClick方法

所以,我收到了这个错误

11-15 16:55:40.617: E/AndroidRuntime(316): java.lang.IllegalStateException: Could not find a method ingresarBtnClick(View) in the activity class android.view.ContextThemeWrapper for onClick handler on view class android.widget.Button with id 'ingresarButton'
Run Code Online (Sandbox Code Playgroud)

这是我的布局xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="vertical" android:weightSum="1" android:id="@+id/Login">
    <TextView android:layout_width="wrap_content" android:id="@+id/textView1" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Número de Lecturista" android:layout_height="wrap_content"></TextView>
    <EditText android:inputType="number" android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/numLecEditText" android:maxLength="4">
        <requestFocus></requestFocus>       
    </EditText>
    <TextView android:layout_width="wrap_content" android:id="@+id/textView2" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_height="wrap_content" android:text="PIN"></TextView>
    <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="number" android:password="true" android:id="@+id/pinEditText" android:maxLength="4"></EditText>
    <TableRow android:id="@+id/tableRow1" android:layout_width="match_parent" android:layout_height="wrap_content">
        <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Ingresar" android:id="@+id/ingresarButton" android:onClick="ingresarBtnClick"></Button>
        <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Salir" …
Run Code Online (Sandbox Code Playgroud)

android button

6
推荐指数
2
解决办法
9244
查看次数

禁用为特定提交按钮启用不显眼的验证

我有两个提交按钮返回,继续.单击"返回"时,如何禁用客户端验证.我试图将取消类添加到按钮属性,但它接缝没有帮助.

UPD.实际上这是取消课程.但是如果你动态添加它(通过javascript),它接缝不起作用.

asp.net-mvc submit button unobtrusive-validation

6
推荐指数
2
解决办法
6971
查看次数

设置exitButton.IsCancel = True时,关闭事件两次触发

我意识到当我设置具有属性IsCancel = True的退出按钮时,窗口的关闭事件将触发两次.

    private void exitButton_Click(object sender, RoutedEventArgs e)
    {
        // this button was set attribute IsCancel = True.
        Close();          
    }

    private void BaseWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    {          
        MessageBox.Show("test"); // this message box will show twice
                                 // when you click on the exit button
        e.Cancel = true;
    }
Run Code Online (Sandbox Code Playgroud)

这是WPF的错误吗?有解决方法吗?

Ps:抱歉,我忘了说只有从父窗口调用窗口时才会出现此错误.

wpf events button

6
推荐指数
1
解决办法
2431
查看次数

如何使用Knockout.js绑定一组动态的jQuery Mobile按钮?

我正在使用jQuery Mobile(jQM)和Knockout.js(ko)来开发应用程序.在这个应用程序中,我需要生成由不断更新的Web服务定义的可变数量的按钮.

所以,在我的标记中,我有:

<div id="answerPage-buttons" data-bind="foreach: buttonsLabels">
    <button data-role="button" data-inline="true" data-theme="b" data-bind="text: text, click: $root.submitAnswer" />
</div>
Run Code Online (Sandbox Code Playgroud)

buttonLabels是从Web服务返回的短字符串列表.它被定义为:

self.buttonLabels = ko.observableArray();
Run Code Online (Sandbox Code Playgroud)

当按钮不是"jQM样式"时,这一切都正常.但是,当我使用它们设置样式时:

$("#answerPage-buttons").trigger("create");
Run Code Online (Sandbox Code Playgroud)

更新期间出现问题.

问题似乎是jQM将按钮包装在一个div(带有兄弟跨度)中,以使它们看起来很漂亮和移动.但是,当ko通过绑定应用更新时,它只删除标记,留下周围的东西,并添加新的按钮标记 - 然后由jQM触发器调用设置样式.

所以,我最终得到了一个不断增长的按钮列表 - 只有最后一组按钮可操作(因为之前的按钮元素被移除了,但所有样式仍然存在).

我想,通过在observable更新后立即进行以下调用,我设法解决了这个问题:

$("#answerPage-buttons div.ui-btn").remove();
Run Code Online (Sandbox Code Playgroud)

但是,我的感觉是,可能有更好的方法.在那儿?

button jquery-mobile knockout.js

6
推荐指数
1
解决办法
980
查看次数

如何在每次点击时更改按钮的图像?

我创建了一个button在layout.在Drawable我创建了一个XML file名为的文件夹中btn01_state.将btn01_state.xml被分配给button通过创建我" android:background=@drawable/btn01_state"

现在,button有一个默认的imageimg1.当我click在上面时button,image1变为img2,一旦我释放了点击的鼠标按钮,image2再次变为img1.

我想要做的是,用evey点击改变按钮的图像.

例如,最初btn01有img01

如果按下btn01 ==>将img of btn01设置为img02并保持img02直到再次按下btn01.现在,btn01上有img02.

按下btn01时,将img01设置为btn01.

我希望这更能澄清我想做的事情.

btn_selector:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/android_blue"
      android:state_pressed="true" />
<item android:drawable="@drawable/ic_launcher"
      android:state_focused="true" />
<item android:drawable="@drawable/ic_launcher" />
Run Code Online (Sandbox Code Playgroud)

main.xml中

<Button 
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:id="@+id/btn01"
    android:background="@drawable/btn01_state"/>
Run Code Online (Sandbox Code Playgroud)

android button imagebutton xml-drawable

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

在带有文本的按钮中缩放drawableLeft

我有一个带文字的按钮和左边的抽屉.有没有什么方法可以在保持纵横比的同时将可绘制比例调整到合适的尺寸(填充按钮的高度)?

我的布局相关摘录:

        <Button 
            android:text="@string/add_fav"
            android:id="@+id/event_fav_button"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:drawableLeft="@drawable/star_yellow"/>  
Run Code Online (Sandbox Code Playgroud)

scaling android button drawable

6
推荐指数
1
解决办法
7114
查看次数

带有Button的Android ExpandableListView Parent

我正在努力实现这样的目标.可扩展列表由某些类别的名称组成,单击父级时,它会显示该类别中所有子级的列表.现在,假设我想动态地将孩子添加到任何类别?我怎么做 ?我是否按下列表中的每个父母点击一个按钮,在其下面添加一个新的孩子?

但是在不同的论坛中,我开始意识到在每个父级中设置按钮点击处理程序并不容易.但如果这是唯一的方法,有人可以给我一些示例代码吗?

我找到了这个帖子但是无法在我的代码中实现它. 使用Button,Android Row变为Unclickable

android button expandablelistview

6
推荐指数
1
解决办法
7251
查看次数

CSS - 图像内的位置按钮

我有包含图像的div,我需要在图像中放置一个按钮到图像的右上角,当我这样做时

#button_id{
position: relative;
    left: 270px;
    top: 30px;
}
Run Code Online (Sandbox Code Playgroud)

这样做是将按钮图像放在其他地方,它将图像向左和向下移动,但是现在按钮可以在条形图中从最初放置到div最右边的位置点击.当我试试这个

#button_id{
     position: relative;
     float: right; padding: 0px -40px -15px;
}
Run Code Online (Sandbox Code Playgroud)

它将按钮向右移动但不会向下移动.

注意:按钮位于div内部,没有css,它位于中心图像的顶部

html css client client-side button

6
推荐指数
1
解决办法
4万
查看次数