假设我在LinearLayout中有几个按钮,其中2个是:
mycards_button = ((Button)this.findViewById(R.id.Button_MyCards));
exit_button = ((Button)this.findViewById(R.id.Button_Exit));
Run Code Online (Sandbox Code Playgroud)
我注册setOnClickListener()了他们两个:
mycards_button.setOnClickListener(this);
exit_button.setOnClickListener(this);
Run Code Online (Sandbox Code Playgroud)
如何使SWITCH区分Onclick中的两个按钮?
public void onClick(View v) {
switch(?????){
case ???:
/** Start a new Activity MyCards.java */
Intent intent = new Intent(this, MyCards.class);
this.startActivity(intent);
break;
case ???:
/** AlerDialog when click on Exit */
MyAlertDialog();
break;
}
Run Code Online (Sandbox Code Playgroud) <asp:Button runat="server" ID="btnUserDelete" Text="Delete" CssClass="GreenLightButton"
OnClick="BtnUserDelete_Click"
OnClientClick="return UserDeleteConfirmation();"
meta:resourcekey="BtnUserDeleteResource1" />
Run Code Online (Sandbox Code Playgroud)
我试过了:
function UserDeleteConfirmation() {
if (confirm("Are you sure you want to delete this user?"))
return true;
else
return false;
}
Run Code Online (Sandbox Code Playgroud)
和
function UserDeleteConfirmation() {
if (confirm("Are you sure you want to delete this user?")) {
__doPostBack(btnUserDelete, '');
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
而且它们都不起作用.
对于api <21,按钮看起来很好.但是,+ 21版本会创建此边框或阴影,如下图所示.如何在不更改孔主题的情况下摆脱它,但设置样式变量?

在这张彩色图像上可能会更清楚.按钮周围有某种边框.

我的buttonssstyle定义如下:
<style name="buttonTransparent" parent="Base.TextAppearance.AppCompat.Button">
<item name="android:background">#00000000</item>
<item name="android:textColor">@drawable/button_text_blue</item>
<item name="android:textSize">18dp</item>
<item name="android:textAllCaps">false</item>
<item name="android:minHeight">45dp</item>
</style>
<style name="buttonLargeWhite" parent="buttonTransparent">
<item name="android:background">#FFF</item>
<item name="android:layout_marginTop">10dp</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我有一个带YesNoCancel按钮的消息框......
Yes将执行一些操作并关闭应用程序 - 工作正常No将无效并关闭应用程序 - (见下文)Cancel将不执行任何操作并保持应用程序打开 - (见下文).我使用DialogResult.No的No按钮,并DialogResult.Cancel为Cancel按钮.但按其中任何一个都会触发DialogResult.Cancel事件.有什么问题?
如何EditText使用a 清除布局中的所有字段Clear Button.我有一个注册活动,有大约10个不同EditTexts.我知道我可以去拿一个具体的参考然后set.Text(""); 但我正在寻找一种更有活力的优雅方式.可能抓住Layout并遍历那里寻找EditText类型的所有项目,然后将其设置为"".不知道如何做到这一点,并尝试在网上搜索它,但没有运气.任何示例代码?
可以轻松使用标准图标集中的一个图标:
$("#myButton").button({icons: {primary: "ui-icon-locked"}});
Run Code Online (Sandbox Code Playgroud)
但是,如果我想添加一个不属于框架图标集的我自己的图标呢?
我认为这就像给自己的CSS类和背景图像一样容易,但这不起作用:
.fw-button-edit {
background-image: url(edit.png);
}
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我一直试图通过CSS改变输入按钮的背景图像,但它不起作用.
search.html:
<body>
<form name="myform" class="wrapper">
<input type="text" name="q" onkeyup="showUser()" />
<input type="button" name="button" value="Search" onclick="showUser()" class="button"/>
<p>
<div id="txtHint"></div>
</p>
</form>
</body>
Run Code Online (Sandbox Code Playgroud)
search.css:
.button {
background-image: url ('/image/btn.png') no-repeat;
cursor:pointer;
}
Run Code Online (Sandbox Code Playgroud)
什么可能是错的?
甚至内联css似乎没有用.
只是想知道是否有办法让HTML <button>元素链接到一个位置而不将其包装在<a href...标签中?
Button目前看起来像:
<button>Visit Page Now</button>
Run Code Online (Sandbox Code Playgroud)
我不希望有什么:
<a href="link.html"><button>Visit Page Now</button></a>
Run Code Online (Sandbox Code Playgroud)
该按钮未在表单中使用,因此<input type="button">不是一个选项.我只是想知道是否有一种方法可以链接这个特定元素,而无需将其包装在<a href标签中.
期待听到一些选择/意见.
我有两个并排的按钮,我想在它们之间有一些.
以下代码将有2个按钮紧挨着.我已经尝试了div的余量,并且在两者之间无法获得一些不错的空间.
<div style="text-align: center">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="89px" OnClick="btnSubmit_Click" />
<asp:Button ID="btnClear" runat="server" Text="Clear" Width="89px" OnClick="btnClear_Click" />
</div>
Run Code Online (Sandbox Code Playgroud) 我正在使用两个按钮.同时单击两个按钮时,它将一次进入不同的活动.怎么避免这个?
我试过这样的,但它不起作用请保存....
public class MenuPricipalScreen extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_principal_layout);
findViewById(R.id.imageView2).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
disable(findViewById(R.id.imageView3));
Intent intent = new Intent(MenuPricipalScreen.this,
SelectYourLanguageVideo.class);
startActivity(intent);
}
});
findViewById(R.id.imageView3).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
disable(findViewById(R.id.imageView2));
Intent intent = new Intent(MenuPricipalScreen.this,
CategoryScreen.class);
intent.putExtra("request", "false");
startActivity(intent);
}
});
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
((ImageView) findViewById(R.id.imageView3)).setEnabled(true); …Run Code Online (Sandbox Code Playgroud)