我正在制作一个应用程序,用户按住一个按钮,使手机振动,我不知道如何制作,所以只有当按钮按下它振动,我的代码到目前为止.
package one.two.bn;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View;
import android.widget.Button;
import android.view.View.OnClickListener;
public class Vb extends Activity {
/** Called when the activity is first created. */
private Button button1;
private Vibrator vibrator;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button1 = (Button)findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
public void onClick(View v) {
if(v==button1){
vibrator.vibrate(300000);
}
}
Run Code Online (Sandbox Code Playgroud)
如果有任何可以帮助感谢很多.
我对Greasemonkey的世界相当新,我想知道如何在JavaScript中创建一个按钮.
比如说我想在YouTube或Google上放一个按钮?我该如何调用它或制作它?
我很困惑,无法找到任何东西.除非有人与这些网站的HTML进行交互并将它们添加到Greasemonkey脚本中吗?
使用Ionic框架,我正在尝试创建一组三个按钮作为单选按钮:

如果我点击早餐,我希望午餐和晚餐回到正常(白色)状态,早餐变成蓝色.
使用我当前的代码,我无法使用此功能,虽然我可以让按钮切换颜色,稍微随机(也许我只是不理解ng-class指令).
这是我的HTML代码:
<div class="bar bar-subheader">
<div class="button-bar">
<a class="button" ng-class="{'button-positive' : !isActiveB, 'none': isActiveB}" ng-click="active('breakfast')">Breakfast</a>
<a class="button" ng-class="{'button-positive' : !isActiveL, 'none': isActiveL}" ng-click="active('lunch')">Lunch</a>
<a class="button" ng-class="{'button-positive' : !isActiveD, 'none': isActiveD}" ng-click="active('dinner')">Dinner</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我的JS:
$scope.active = function(meal) {
switch (meal) {
case 'breakfast':
$scope.$broadcast('slideBox.setSlide', 0);
$scope.isActiveB = $scope.isActiveB;
$scope.isActiveL = !$scope.isActiveL;
$scope.isActiveD = !$scope.isActiveD;
break;
case 'lunch':
$scope.$broadcast('slideBox.setSlide', 1);
$scope.isActiveB = !$scope.isActiveB;
$scope.isActiveL = $scope.isActiveL;
$scope.isActiveD = !$scope.isActiveD;
break;
case 'dinner':
$scope.$broadcast('slideBox.setSlide', 2);
$scope.isActiveB …Run Code Online (Sandbox Code Playgroud) 如何实现在材料设计指南中规定的切换按钮在这里?
是否可以从Android设计支持库中获得开箱即用,或者是否有可用的第三方库?
使用 AspNet Blazor 及其 EditForm:我正在创建一个简单的表单,它应该包含一个更新和一个删除按钮。我似乎没有找到任何关于如何将参数传递给提交的示例。
我试图在删除按钮中放置一个@onclick 指向DeleteObject,但后来我没有得到验证(在这种情况下我实际上不需要验证,但无论如何我都想这样做),而且在之后也调用了 SaveObject删除...
<EditForm Model="@selectedCar" OnValidSubmit="@SaveObject">
<DataAnnotationsValidator />
<ValidationSummary />
....My <InputText>'s for all values I have in my object
<button type="submit" class="btn btn-primary" value="Save">Spara</button>
<button type="submit" class="btn btn-primary" value="Delete">Delete</button>
</EditForm>
@code {
[Parameter]
public string Id { get; set; }
CarModel selectedCar;
protected override async Task OnInitializedAsync()
{
selectedCar = await _CarService.GetCar(int.Parse(Id));
}
protected async Task SaveObject()
{
selectedCar.Id = await _CarService.SaveCar(selectedCar);
}
protected async Task DeleteObject(int Id)
{
selectedCar.Id = await _CarService.DeleteCar(selectedCar);
} …Run Code Online (Sandbox Code Playgroud) 由于“凸起”按钮已被弃用,我用“凸起”按钮代替。但我无法增加升高按钮的高度。
class ZuzuButton extends StatelessWidget {
final Function onTapped;
final String name;
final double height;
final TextStyle textStyle;
final double radius;
final List<BoxShadow> shadow;
final Color color;
final bool enable;
ZuzuButton({this.onTapped,@required this.name,
this.height,this.textStyle,this.radius,this.shadow,this.color,this.enable=true});
@override
Widget build(BuildContext context) {
return Container(
height: height==0?48.0:height,
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(radius!=null?radius:30.0),
border: enable? Border.all(
width: color!=null?0.0:1.0,
color: color!=null?color:Color(0x407F16F0),
):null,
boxShadow: enable?(shadow==null?[
BoxShadow(
color: Color(0x407F16F0),
offset: Offset(0.0, 8.0),
spreadRadius: 0,
blurRadius: 20,
),
]:shadow):null,
),
child: ElevatedButton(
child: Container(
child: Center(
child: Text(name,style: textStyle!=null?textStyle:null,),
), …Run Code Online (Sandbox Code Playgroud) 这就是我想要实现的目标:

因此,我连续创建了 2 个圆形按钮,并根据是否选择它们提供了不同的背景颜色。目标是创建一种选项卡/切换的错觉。
未选中的按钮将具有与该行的背景颜色相同的颜色。不幸的是,由于行是矩形形状,因此在拐角处有残留空间,但仍然显示背景颜色。


这是我的按钮代码
val cornerRadius = 20.dp
var selectedIndex by remember { mutableStateOf(0)}
val configuration = LocalConfiguration.current
val screenWidth = configuration.screenWidthDp.dp
val items = listOf(
OutlinedButton(onClick = { /*TODO*/ }) {
},
OutlinedButton(onClick = { /*TODO*/ }) {
})
Row(
modifier = Modifier
.padding(top = 8.dp)
.wrapContentHeight()
.width(screenWidth).background(color = Color.Gray).clip(shape = RoundedCornerShape(20.dp))
) {
// Spacer(modifier = Modifier.weight(1f))
items.forEachIndexed { index, item ->
OutlinedButton(modifier = Modifier
.wrapContentHeight()
.width(screenWidth/2),
shape = when (index) {
// left outer button …Run Code Online (Sandbox Code Playgroud) 这应该是一个简单的,我真的认为我所做的是正确的,但显然它不是.我有一个我想用作按钮的图像,我创建了按钮并且正在工作.但现在我只想显示这个图像,而不是站立的android"按钮".
有人知道怎么做吗?
我是Android和Java的新手,但我已经设法自学并在stackoverflow上找到大多数问题的答案而无需提问.到现在....
在这里,我有许多彩色按钮,当点击时,将颜色改变为一系列不同的颜色.
有许多按钮定义为例如:
<Button
android:id="@+id/button17"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/orange_button"
android:gravity="center"
android:onClick="onClick" />
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何更改android:background使用代码将上面的示例更改为黄色,例如,单击按钮时.
在下面的代码中,clickedButton是我需要更改背景的按钮的ID.
public void onClick(View v) {
int id=v.getId();
String clickedButton = getResources().getResourceEntryName(id);
Change button to Yellow here??
// Temporary code below to check which button was pressed
// and convert its number to an integer to eventually access an array
final TextView tvGameTimer = (TextView) findViewById(R.id.tvGameTimer);
int buttonNumber = Integer.parseInt(clickedButton.substring(6,8));
tvGameTimer.setText("" + buttonNumber);
}
Run Code Online (Sandbox Code Playgroud)
我使用自定义按钮样式来定义按钮颜色:
res/drawable/yellow_button.xml
res/drawable/blue_button.xml
res/drawable/red_button.xml
res/drawable/orange_button.xml
res/drawable/green_button.xml
Run Code Online (Sandbox Code Playgroud)
现在我只需要弄清楚如何将按钮从橙色更改为黄色.然后,我可以添加逻辑以在应用需要时更改颜色.
非常感谢任何帮助.
如何使用Swift模拟View中的按钮按下.我正在尝试获取日历权限并设置功能以在我单击当前运行的开始按钮时检查此授权
@IBAction func start(sender: AnyObject) {
//loads prompt to "Allow" or "Don't Allow" calendar permissions
eventStore.requestAccessToEntityType(EKEntityTypeEvent, completion: handler)
//checkAuth function looks at calendar authorization to get current status
and then acts accordingly to dismiss View or load Privacy Settings
checkAuth()
}
Run Code Online (Sandbox Code Playgroud)
我需要能够模拟按下"开始"按钮的按钮再次触发start()func.到目前为止,我发现的唯一一件事似乎是在Objective-C中
[buttonObj sendActionsForControlEvents: UIControlEventTouchUpInside];
我不熟悉Obj-C,如果可能的话,需要一种在Swift中实现它的方法......谢谢
button ×10
android ×4
javascript ×2
angularjs ×1
background ×1
blazor ×1
dart ×1
drawable ×1
flutter ×1
greasemonkey ×1
height ×1
image ×1
ios ×1
ios8 ×1
radio-button ×1
row ×1
submit ×1
swift ×1
tampermonkey ×1
vibration ×1