我一直在寻找一种方法来做到这一点,但找不到任何东西
我想要一个:
禁用输入文本字段,称为#XX.此输入将存储来自datepicker的选定值(因为此输入被禁用,我将无法使用它来触发datePicker)
按钮,除了#XX.当用户单击此按钮时,将显示datePicker.用户将选择日期,此日期将分配给禁用的输入#XX.
我想这样,所以用户不能手动更改 - 通过输入垃圾 - 选定的日期
另外,我应该验证是否使用#XX.val()输入了日期?或者,还有更好的方法?
我想在用户点击注销时禁用后退按钮我只删除该用户的cookie而不是我的应用程序中的会话.并且想要禁用"后退"按钮
if(getCookie('username') == ""){
Disable back button;// we use "window.history.redirect" for javascript i look jquery for this
}
Run Code Online (Sandbox Code Playgroud)
请帮我..
我正在尝试制作4个按钮,在Android上的纵向视图中均匀分布.
空间应根据屏幕尺寸向上和向下缩放,每个按钮和边框之间的空间均匀.
我尝试使用线性布局,重量和布局重力,但似乎我不能垂直居中按钮.
这是Android布局的错误吗?更可能只是我.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center"
>
<Button
android:id="@+id/btn_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn_f"
>
</Button>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center"
>
<Button
android:id="@+id/btn_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn_b"
>
</Button>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center"
>
<Button
android:id="@+id/btn_a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn_a"
>
</Button>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center"
>
<Button
android:id="@+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
>
</Button>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我在Android中创建了自定义ToggleButtons,因为所有按钮都继承自相同的xml,我想根据状态更改它们的行为方式,所以当检查状态时我想改变阴影颜色,但这似乎不可能当前的SDK.
我创建了一个包含button_colors的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_checked="true"
android:color="#FFFFFF" />
<item
android:color="#000000" />
</selector>
Run Code Online (Sandbox Code Playgroud)
但这似乎只适用于文本颜色而不是文本上的阴影颜色.有什么我想念的吗?而不是在代码中手动为每个按钮执行此操作,因为我希望将其应用于应用程序中的每个按钮.
更新编辑:
我的选择器目前看起来像这样
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_checked="true"
android:drawable="@drawable/button_gradient_selected" />
<item
android:drawable="@drawable/button_gradient" />
</selector>
Run Code Online (Sandbox Code Playgroud)
但正如我在下面的评论员中所提到的,我似乎无法从这里改变样式/文本颜色阴影,因为它似乎只能采用可绘制的颜色.
当我尝试在此处按钮上放置不同的样式时,它会强制关闭或根据状态不改变样式.当我只尝试在这里放置样式并且在样式中设置drawable它强制关闭.无论哪种方式,它似乎都不起作用.
我知道这是一个以前曾多次被问过的问题,但我似乎无法在我的代码中解决它.我有两个按钮,当按下一个按钮时,我希望将其保持在选定状态,反之亦然.我尝试过使用setSelected和setPressed,但我似乎无法让它工作.这是我正在使用的代码:
region_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
objects = category;
adap.notifyDataSetChanged();
proximity_button.setPressed(false);
region_button.setPressed(true);
}
});
proximity_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
objects = proximity;
adap.notifyDataSetChanged();
region_button.setPressed(false);
proximity_button.setPressed(true);
}
});
Run Code Online (Sandbox Code Playgroud)
编辑: 根据评论,我需要添加我有按钮的自定义xml背景,并希望保留当前的外观.
在许多iPhone应用程序上,我看到一个蓝色的圆形按钮,当点击它时,会显示有关应用程序的信息.这是内置于iOS SDK中的内容,还是只是一个带有自定义图像的自定义按钮?
我想通过按下按钮在ImageView中打开一个图像.我需要图像可缩放和可滚动.我怎样才能最好地完成这个?谢谢!
图像可以是PNG或JPG
非常感谢!
这是我的新代码,你不介意浏览并给我一个TAG,ZOOM等所有问题的解决方案...我也知道我需要添加我的图像res到它
package com.DS;
import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.FloatMath;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class CheatMathActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button button1 = (Button) findViewById(R.id.button1);
button1.setOnTouchListener(new View.OnTouchListener(){
public void onTouch(View v) {
//Opens Algebra Image
public …Run Code Online (Sandbox Code Playgroud) 有多种方法可以创建HTML按钮以导航到其他页面.
方法1
<button id="btn_click">Click Me</button>
<script>
$('#btn_click').on('click', function() { window.location = 'http://www.google.com'; });
</script>
Run Code Online (Sandbox Code Playgroud)
方法2
<button onclick="window.location='http://www.google.com'">Click Me</button>
Run Code Online (Sandbox Code Playgroud)
方法3
<a class="click-me" href="http://www.google.com">Click me</a>
<style>
.clickMe {
-moz-appearance: button;
-ms-appearance: button;
-o-appearance: button;
-webkit-appearance: button;
appearance: button;
text-decoration: none;
color: #000;
padding: 0.2em 0.4em;
}?
</style>
Run Code Online (Sandbox Code Playgroud)
appearance是一个CSS3属性)方法4
<form action="http://www.google.com">
<button>Click Me</button>
</form>
Run Code Online (Sandbox Code Playgroud)
<form>标签.如果有另一个提交按钮,则不起作用程序员,哪种方法是最有效的(因此广泛使用),为什么?
注意:我们可以将其作为社区维基吗?
在下面的代码中,我有一个TextField和一个Button.我需要在TextField为空时禁用Button,以便我可以避免向数据库输入空值.如何禁用该按钮?
private VBox addVBox() {
VBox vb1 = new VBox();
vb1.setPadding(new Insets(15, 20, 25, 20));
vb1.setSpacing(15);
vb1.setStyle("-fx-background-color: #333333;");
final Label label = new Label("Staff Details");
label.setFont(Font.font("Arial", FontWeight.BOLD, 20));
label.setTextFill(Color.WHITE);
TableColumn sub = new TableColumn("Staff Name");
sub.setMinWidth(400);
sub.setCellValueFactory(
new PropertyValueFactory<Staff, String>("subName"));
table.setItems(data);
table.getColumns().addAll(sub);
addSubName = new TextField();
addSubName.setPromptText("Staff Name");
addSubName.setPrefSize(200, 30);
final Button b2 = new Button("Add");
b2.setFont(Font.font("Calibri", FontWeight.BOLD, 17));
b2.setPrefSize(70, 30);
b2.setStyle(" -fx-base: #0066ff;");
b2.setTextFill(Color.BLACK);
b2.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
msg = addSubName.getText();
try {
enterStaff(); …Run Code Online (Sandbox Code Playgroud)