标签: button

android启动用户定义的搜索按钮活动按@手机

当用户按下手机上的搜索按钮时,我正在使用以下代码来启动活动

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if(keyCode == KeyEvent.KEYCODE_SEARCH){
        Util.startActivity(ReviewsDetail.this, KeywordSearch.class);
        return false;
    }else{
        return super.onKeyUp(keyCode, event); 
    }
}
Run Code Online (Sandbox Code Playgroud)

但是这里有几个问题,请看下面的图片.

当按搜索按钮时,它首先在活动顶部显示谷歌搜索框然后开始我想要开始的活动

替代文字

单击后退按钮时显示空闲活动 替代文字

search android button

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

在iPhone应用程序中添加Facebook Like按钮

有谁知道如何在iPhone应用程序中包含一个"按钮".我尝试在内部调用iframe,UIWebView但这不起作用.

iphone facebook button facebook-like

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

如何检测Android上按下和释放按钮的时间

我想启动一个计时器,它在第一次按下按钮时开始,在释放按钮时结束(基本上我想测量按钮按下的时间长度).我将在这两个时间使用System.nanoTime()方法,然后从最后一个中减去初始数字,以获得按住按钮时经过的时间的度量.

(如果您对使用nanoTime()以外的其他方法有任何建议,或者其他一些方法来衡量按钮的按住时间,我也会对这些人开放.)

谢谢!安迪

java android pressed timer button

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

SwiftUI:如何处理轻按和长按按钮?

我在 SwiftUI 中有一个按钮,我希望能够对“点击按钮”(正常点击/点击)和“长按”执行不同的操作。

这在 SwiftUI 中可能吗?

这是我现在拥有的按钮的简单代码(仅处理“正常”点击/触摸案例)。

Button(action: {self.BLEinfo.startScan() }) {
                        Text("Scan")
                    } .disabled(self.BLEinfo.isScanning)
Run Code Online (Sandbox Code Playgroud)

我已经尝试添加一个“长按手势”,但它仍然只“执行”“正常/短”点击。这是我试过的代码:

Button(action: {self.BLEinfo.startScan() }) {
                        Text("Scan")
                            .fontWeight(.regular)
                            .font(.body)
                        .gesture(
                            LongPressGesture(minimumDuration: 2)
                                .onEnded { _ in
                                    print("Pressed!")
                            }
                        )
                    }
Run Code Online (Sandbox Code Playgroud)

谢谢!

杰拉德

button long-press swiftui

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

如何在C#中设置/更改/删除按钮上的焦点样式?

我有几个按钮,我修改了它们的外观.我已将它们设置为带有背景和自定义边框的平面按钮,因此它们看起来很漂亮而且不再像普通按钮那样(实际上,它们现在看起来像Office 2003按钮;-).按钮的边框为一个像素.

然而,当按钮被选中时(通过点击或键盘操作获得焦点,如按Tab键),按钮会突然获得相同颜色的额外边框,因此使其成为两个像素的边框.此外,当我禁用一个像素边框时,按钮不会在焦点上获得一个像素边框.

在网上这个问题被问了很多,比如'如何禁用对按钮的关注',但这不是我想要的:焦点应该仍然存在,只是不显示是以现在的方式.

有什么建议?:-)

c# focus button winforms

24
推荐指数
5
解决办法
6万
查看次数

android - 按钮样式

普通按钮看起来像:

替代文字

现在,请让我知道,我如何制作一个简单的按钮与附加图像按钮相同(即按钮角形是圆形的,两个按钮之间也没有间隙)

替代文字

android styles button

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

选中复选框列表中的所有复选框,只需单击一下c#

我想要一个按钮,一旦点击,它将选中我的核对表框中的所有复选框.我搜索了可能的答案,但我总是看到asp.net和javascript的例子.我在c#中使用Windows表单.谢谢你的回复.

c# checkbox button winforms checklistbox

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

将AlertDialog按钮对齐到中心

我使用此代码进行Android(Java)编程:

public static MessageBoxResult showOk(
        Context context, String title, String message, String okMessage)
{
    okDialogResult = MessageBoxResult.Closed;

    // make a handler that throws a runtime exception when a message is received
    final Handler handler = new Handler()
    {
        @Override
        public void handleMessage(Message mesg)
        {
            throw new RuntimeException();
        }
    };

    AlertDialog.Builder alert = new AlertDialog.Builder(context);
    alert.setTitle(title);
    alert.setMessage(message);

    alert.setPositiveButton(okMessage, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            okDialogResult = MessageBoxResult.Positive;
            handler.sendMessage(handler.obtainMessage());
        }
    });

    AlertDialog dialog = alert.show();


    // align button …
Run Code Online (Sandbox Code Playgroud)

android button alignment android-alertdialog

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

带边框的材料设计按钮

我知道如何使用颜色填充制作材质设计按钮:

style="@style/Widget.AppCompat.Button.Colored"
Run Code Online (Sandbox Code Playgroud)

并且没有边框的透明按钮:

style="@style/Widget.AppCompat.Button.Borderless.Colored"
Run Code Online (Sandbox Code Playgroud)

但是,有没有办法让Material Design设计成边框(透明内部)按钮?像下面的东西?

在此输入图像描述

android button android-button material-design material-components-android

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

Android,设置按钮的背景颜色会失去涟漪效果

在向Android按钮添加颜色后,它会失去其涟漪效果,使用户感觉有响应点击.我该如何解决?我已经搜索了很多解决方案,但我找不到一个不明确的明确解决方案.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context=".ClockInOutFragment">


    <AnalogClock
        android:id="@+id/clock"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/date_and_time"/>


    <RelativeLayout
        android:id="@+id/date_and_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp">

        <TextView
            android:id="@+id/time_digits"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="12:10"
            android:textSize="45sp"/>

        <TextView
            android:id="@+id/am_pm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/time_digits"
            android:layout_toRightOf="@+id/time_digits"
            android:paddingLeft="3dp"
            android:text="PM"
            android:textSize="20sp"/>

        <TextView
            android:id="@+id/date"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/time_digits"
            android:text="Mon, July 11"
            android:textSize="22sp"/>
    </RelativeLayout>

    <!--Clock in and out buttons-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal">

        <Button
            android:id="@+id/textView3"
            android:layout_width="0dp"
            android:layout_height="56dp"
            android:layout_weight="1"
            android:background="#4CAF50"
            android:gravity="center"
            android:text="Clock In"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#FFFFFF"/>

        <!--Divider between the clock in and out button-->
        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#B6B6B6"/>

        <Button …
Run Code Online (Sandbox Code Playgroud)

android click button effect ripple

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