请查看下面的自定义对话框.我在对话框上有一个edittext字段,如果文本字段为空,我想禁用positiveButton.我可以为文本字段获取一个charListener,但我不确定如何设置positivebutton禁用或启用该侦听器?正负按钮的参考是什么?
case DIALOG_TEXT_ENTRY:
// This example shows how to add a custom layout to an AlertDialog
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.alert_dialog_text_entry)
.setView(textEntryView)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked OK so do some stuff */
}
})
.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked cancel so do some stuff */
}
}) …Run Code Online (Sandbox Code Playgroud) 我有一个对象让我们调用它 ObjectA
并且该对象有10个属性,这些属性都是字符串.
var myObject = new {Property1="",Property2="",Property3="",Property4="",...}
Run Code Online (Sandbox Code Playgroud)
无论如何要检查所有这些属性是空还是空?
那么任何返回true或false的内置方法呢?
如果它们中的任何一个不为null或为空,则返回将为false.如果所有这些都是空的,它应该返回true.
我的想法是,我不想编写10 if语句来控制这些属性是空还是null.
谢谢
这就是我现在所拥有的
hidden="@(Model.IsOwnedByUser||!Model.CanEdit)"
Run Code Online (Sandbox Code Playgroud)
这在Chrome上工作正常,但在Internet Explorer上并不隐藏
我也试过可见性设置假但没有运气.
然后我发现了另一种风格如下
style="@(Model.IsOwnedByUser||!Model.CanEdit)?'display:none'""
Run Code Online (Sandbox Code Playgroud)
我无法让它奏效.使用Razor语法隐藏元素的正确格式是什么?
或者我会使用Jquery来隐藏元素.但实际上是否可以打印出jquery语句来隐藏页面加载时的元素?
我试图将文件传递给File(String path)类.有没有办法在assets文件夹中找到文件的绝对路径并将其传递给File().我试过file:///android_asset/myfoldername/myfilename作为路径字符串,但它没有工作.任何的想法?
Artist和之间存在着多对多的关系ArtistType.我可以轻松添加ArtistType如下的艺术家
foreach (var artistType in this._db.ArtistTypes
.Where(artistType => vm.SelectedIds.Contains(artistType.ArtistTypeID)))
{
artist.ArtistTypes.Add(artistType);
}
_db.ArtistDetails.Add(artist);
_db.SaveChanges();
Run Code Online (Sandbox Code Playgroud)
这将使用正确的映射更新多对多关联表.但是,当我尝试从表中删除任何项目时,我没有得到任何错误,但它没有从表中删除它?
foreach (var artistType in this._db.ArtistTypes
.Where(at => vm.SelectedIds.Contains(at.ArtistTypeID)))
{
artistDetail.ArtistTypes.Remove(artistType);
}
this._db.Entry(artistDetail).State = EntityState.Modified;
this._db.SaveChanges();
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
switch (am.getRingerMode()) {
case AudioManager.RINGER_MODE_SILENT:
Log.i("MyApp","Silent mode");
break;
case AudioManager.RINGER_MODE_VIBRATE:
Log.i("MyApp","Vibrate mode");
break;
case AudioManager.RINGER_MODE_NORMAL:
Log.i("MyApp","Normal mode");
break;
}
Run Code Online (Sandbox Code Playgroud)
从上面的代码我可以获得振铃模式.我要做的就是听铃声模式改变并调用一个函数.
我被告知的是我可以注册AudioManager.RINGER_MODE_CHANGED_ACTION并在broadcastreceiver onReceive方法中监听更改意图.听起来很清楚.但我是android的新手,真的不知道如何写它.有没有人可以写一段代码,并显示它是如何工作,而不是说使用这个或那:)谢谢
我有一张叫做的桌子Products.
该表包含超过300万条目.每天大约有5000个新条目.这只发生在2分钟的夜晚.
但是这个表每天晚上查询可能会超过20 000次查询.
SELECT Price
FROM Products
WHERE Code = @code
AND Company = @company
AND CreatedDate = @createdDate
Run Code Online (Sandbox Code Playgroud)
表结构:
Code nvarchar(50)
Company nvarchar(10)
CreatedDate datetime
Run Code Online (Sandbox Code Playgroud)
我可以看到这个查询大约花了一秒钟从Products表返回一个结果.
productId表中没有列,因为它不需要.所以表中没有主键.
我想以某种方式改进此查询以更快地返回结果.
我之前从未使用过索引.在这个表上使用索引的最佳方法是什么?
如果我提供主键,您认为它会加快查询结果吗?请记住,我仍然需要通过提供3个参数来查询表
WHERE Code = @code
AND Company = @company
AND CreatedDate = @createdDate.
Run Code Online (Sandbox Code Playgroud)
这是强制性的.
正如我所提到的那样,桌子每天在2分钟内获得新的参赛作品.这会如何影响索引?
如果我使用索引,哪个列最适合使用以及我是否应该使用聚簇索引或非聚簇索引?
是否有使用的方式autocomplete="off"在<asp:Login> </asp:login>.我试图将asp:login转换为模板,并在asp:TextBox元素中放置autocomplete ="off"属性,但这会破坏登录过程的其他部分.有没有一种方法可以在不使用javascript和不转换为模板的情况下禁用自动完成功能.如果它可能背后的代码是好的.期待您的建议.谢谢
这是Page_Load中的代码
if (!Page.IsPostBack)
{
var control = this.FindControlRecursive(LoginArea, "UserName") as TextBox;
if (control != null)
{
control.Attributes.Add("autocomplete", "off");
}
var control2 = this.FindControlRecursive(LoginArea, "Password") as TextBox;
if (control2 != null)
{
control2.Attributes.Add("autocomplete", "off");
}
}
Run Code Online (Sandbox Code Playgroud)
在这里aspx页面:
<asp:Login ID="LoginArea" runat="server" SkinID="Login" CssSelectorClass="PrettyLogin"
DestinationPageUrl="Home.aspx" LoginButtonImageUrl=""
LoginButtonText="login button"
LoginButtonType="Button"
UserNameLabelText="username>"
PasswordLabelText="password"
TitleText="title"
RememberMeSet="false" DisplayRememberMe="false"
FailureText="failed"
ToolTip="tool tip"
PasswordRecoveryText=""
PasswordRecoveryUrl="urlforpasswordrecovery"
CreateUserText=""
CreateUserUrl="" OnLoggedIn="LogOn_LoggedIn"
OnLoggingIn="LogOn_LoggingIn" OnLoginError="LogOn_Error" >
</asp:Login>
Run Code Online (Sandbox Code Playgroud) 我在表中有一个列update_date,类型是时间戳.我使用phpmyadmin下拉菜单设置了CURRENT_TIMESTAMP的deault值.但是后来当我运行sql UPDATE x SET时...如果只有任何列中的更改,它会更新时间戳列.我想要实现的是每次更新sql运行时是否有更改都设置当前时间.有没有办法在mysql中执行它或者我需要在每次调用更新时显式设置update_date?
谢谢
问题是你可以看到我无法在showDialog()之前动态设置edittext的值.
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity {
private static final int DIALOG_TEXT_ENTRY = 7;
private int user_id;
private int dialogChoice;
private String mobileNum;
private EditText input2 ;
private EditText input1 ;
public TextView textView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.alert_dialog_text_entry);
TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
mobileNum =tm.getLine1Number(); …Run Code Online (Sandbox Code Playgroud) android ×4
c# ×3
dialog ×2
asp.net ×1
asp.net-mvc ×1
assets ×1
autocomplete ×1
button ×1
database ×1
dbcontext ×1
file-io ×1
html ×1
jquery ×1
many-to-many ×1
mysql ×1
performance ×1
properties ×1
razor ×1
sql-server ×1
timestamp ×1
xml ×1