在我的WPF应用程序中,我只想更改组合框的背景颜色.我不是指下拉,我想要的只是选择背景设置的任何项目.就像设置按钮的背景一样 - 当控件显示在屏幕上时,它应该具有LightYellow背景.而已.我在网上搜索了很多,但到处都可以找到下拉背景颜色的解决方案.我尝试将SolidColorBrush和Style.Triggers应用到Combobox的TextBlock,但没有成功.通过添加SolidColorBrush线,我得到了我的下拉背景设置,但这不是我想要的.我的代码是:
<ComboBox ItemsSource="{Binding MtrCm}" SelectedValue="{Binding WellboreDiameter_Unit, Mode=TwoWay}" Grid.Row="1" Height="23" HorizontalAlignment="Right" Margin="0,26,249,0" x:Name="cboWellDiameter" VerticalAlignment="Top" Width="120" Background="LightYellow" >
<ComboBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="Yellow" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Yellow" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Yellow" />
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ComboBoxItem}}" Value="True">
<Setter Property="Background" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Resources>
</ComboBox>
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我设置他正在寻找的所需组件的背景.
谢谢
我动态创建TextView并希望将文本设置为可链接.文字值为" Google ".我提到了像这样的互联网和博客,它以同样的方式显示,但我无法产生预期的结果.
我尝试了不同的方法,但我看到的输出是仅包含文本的整个文本.我试过的代码是:
TextView tv1 = new TextView(this);
tv1.setLayoutParams(textOutLayoutParams);
// Make Linkable
tv1.setMovementMethod(LinkMovementMethod.getInstance());
tv1.setText(Html.fromHtml(l.getLeftString()));
/*SpannableString s = new SpannableString(l.getLeftString());
Linkify.addLinks(s, Linkify.WEB_URLS);
tv1.setText(s);
tv1.setMovementMethod(LinkMovementMethod.getInstance());
*/
dialogLayout.addView(tv1);
Run Code Online (Sandbox Code Playgroud)
在我的输出中,我看到" 谷歌 ",没有链接.我也尝试过清洁项目并再次构建它,但没有成功.我希望只有"Google"标有蓝色下划线(默认情况下),点击Google后,浏览器会打开http://google.com.
我的代码缺少什么来获得输出?BTW For REF:我使用64位Win 7,Java,Eclipse,Android API 8-2.2
任何帮助都非常感谢.
我正在尝试执行HTTP Get请求,但我继续收到Error Domain = NSURLErrorDomain Code = -1012错误.我的代码是:
@try {
NSString *url = [[NSString alloc] initWithFormat:@"%@%@", @"http://api.mintchat.com/agent/chats/", agentSecret];
NSLog(@"******Agents Active List URL Str - %@", url);
NSURL *nsUrl = [NSURL URLWithString:url];
NSLog(@"******Agents Active List URL - %@", nsUrl);
// Make the request, returning a JSON response, just as a plain old string.
//NSData *jsonDataString = [[NSString stringWithContentsOfURL:[NSURL URLWithString:url] encoding:NSUTF8StringEncoding error: nil] dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:nsUrl];
[request setHTTPMethod:@"GET"];
[request setValue:API_ID forHTTPHeaderField:@"X-API-ID"];
[request setValue:API_SECRET forHTTPHeaderField:@"X-API-SECRET"]; …Run Code Online (Sandbox Code Playgroud) 众所周知,我们可以创建一个EventHandler并向其添加N次方法.喜欢:
// Declare and EventHandler
public event EventHandler InternetConnectionAvailableEvent;
private void OnInternetConnectionAvailableEvent()
{
if (InternetConnectionAvailableEvent != null)
{
EventHandler handle = InternetConnectionAvailableEvent;
EventArgs e = EventArgs.Empty;
handle(this, e);
}
}
// IN OTHER CLASS WHERE I USE THE EVENT
// Set the method name to handle the event
monitorInternet.InternetConnectionAvailableEvent += HandleInternetConnectionEvent;
void HandleInternetConnectionEvent(object sender, EventArgs e)
{
if (syncContext != null)
{
MonitorInternetConnection mic = (MonitorInternetConnection)sender;
if (mic != null)
{
syncContext.Post(o => InternetConnected(), null);
}
}
}
// To …Run Code Online (Sandbox Code Playgroud) 我的xml文件中有2个按钮,包含RelativeLayout.在我的课程中,我扩展了Dialog并实现了OnClickListener,并添加了OnClick(View v)方法.但不知何故,单击按钮时,onClick代码永远不会执行.任何人都可以帮我找到我的代码问题:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:padding="10px">
......
<Button android:id="@+id/saveBtn_settingDlg" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/editText1"
android:layout_marginLeft="10px" android:text="Save" />
<Button android:id="@+id/closeBtn_settingDlg" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Close" android:layout_alignBaseline="@+id/saveBtn_setting"
android:layout_toRightOf="@+id/saveBtn_setting" android:onClick="CloseDialog" />
Run Code Online (Sandbox Code Playgroud)
类
public class SettingDialog extends Dialog implements OnClickListener {
private Button btn_save, btn_close;
// In Constructor
btn_save = (Button) findViewById(R.id.saveBtn_settingDlg);
btn_close = (Button) findViewById(R.id.closeBtn_settingDlg);
btn_save.setOnClickListener(this);
btn_close.setOnClickListener(this);
@Override
public void onClick(View v) {
if (v == btn_save)
SaveSettings();
else if (v == btn_close)
CloseDialog();
return;
}
private void CloseDialog() {
disposeAll();
this.dismiss(); …Run Code Online (Sandbox Code Playgroud) 首先,我认为这个论坛不适合我的问题,所以如果它在错误的地方,请在适当的地方请原谅和放置.我没有为我的问题找到合适的论坛.
我开发了一个C#应用程序(Win Forms).现在我需要处理它的版本编号.我无法弄清楚最好的方法是什么.我希望版本号简单,如1.2或1.2.1.我读到了关于SVN版本的内容,但在这个阶段看起来似乎并不那么令人困惑.应用程序有不同的版本类型 - 1个带安装程序,1个没有安装程序.
我认为发布版本和开发版本应该是相同的 - 如果我错了,请纠正我.它应该自动处理还是手动更改?处理应用程序版本编号的最佳,简单和简单方法是什么.
我通过https从我的Android客户端调用Web服务.我必须验证从服务器端接收的证书.我怎么做 ?目前这是我用来调用Web服务的代码.
private static String SendPost(String url, ArrayList<NameValuePair> pairs) { // url = "https://....."
errorMessage = "";
String response = "";
DefaultHttpClient hc=new DefaultHttpClient();
ResponseHandler <String> res=new BasicResponseHandler();
HttpPost postMethod=new HttpPost(url);
try {
postMethod.setEntity(new UrlEncodedFormEntity(pairs));
response = hc.execute(postMethod, res);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return response;
}
Run Code Online (Sandbox Code Playgroud)
如何在执行发布期间验证从服务器收到的自签名证书?我必须通过公钥/私钥进行测试.客户端将拥有一个CA文件.我需要客户端使用CA验证服务器证书,该服务是公共的.这与公钥/私钥有关.如何在致电帖子之前从服务器接收证书?
它们是stackoverflow上提供的几个选项和代码片段.我找到的多个链接的多个链接是: 在Android上接受HTTPs证书以及 使用Android和自签名服务器证书的HTTPS GET(SSL)
但我无法弄清楚哪些对我来说是好的/适用的!我不想禁用所有或接受任何.必须检查公钥/私钥/
任何帮助都非常感谢.
我试图Background在用户点击它时更改Button 的颜色.我正在使用触发器来实现它.
我的XAML是:
<UserControl.Resources>
<Style x:Key="myBtnStyle" TargetType="{x:Type Button}">
<!--VerticalAlignment="Top" VerticalContentAlignment="Top" Background="Blue" HorizontalAlignment="Right"
Height="24" Width="25" FontSize="16" FontWeight="Bold" -->
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="Background" Value="Blue" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="25" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontWeight" Value="Bold" />
<Style.Triggers>
<Trigger Property="Button.IsMouseOver" Value="true">
<Setter Property="Background" Value="Yellow" />
</Trigger>
</Style.Triggers>
</Style>
<!--
<ControlTemplate x:Key="btnTemplate" TargetType="{x:Type Button}">
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True" >
<Setter Property="Background" Value="Cyan" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate> --> …Run Code Online (Sandbox Code Playgroud) 我的应用程序有一个Windows Installer.应用程序包还包含Installer类,其中执行其他一些操作在"自定义操作"中执行.
安装程序在安装期间从安装程序安装另一个应用程序.我想知道这个应用程序是否已存在相同版本我不想安装或提供Messagebox asknig重新安装Y/N.
如果我的应用程序已经安装,并且我再次单击相同的安装程序,则会显示"修复"和"删除"选项.但是如果新构建了安装程序,我会收到一个对话框,指出"已经安装了另一个版本...使用"添加删除程序"删除..".所以我无法在没有卸载它的情况下更新exisitng版本.如何更新现有版本?
任何有关这两个查询的帮助或指导都非常感谢.我在网上寻找这些,但无法获得适当的答案.如果你能帮助我,那真的很棒.
码
prouct.xml
<?xml version="1.0" encoding="utf-8" ?>
<Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
ProductCode="My.Bootstrapper.ABC">
<!-- Create Package, Product Manifest http://msdn.microsoft.com/en-us/library/ee335702.aspx
Schema Reference : http://msdn.microsoft.com/en-us/library/ms229223.aspx
-->
<PackageFiles>
<PackageFile Name="XYZ.exe"/>
</PackageFiles>
<InstallChecks>
<!-- If its installed, it will be in Uninstall. DisplayName will be XYZ2.1_rc22
Can still get values of DisplayVersion (2.1_rc22) & UninstallString from this key
-->
<RegistryCheck
Property="IS_XYZ_INSTALLED"
Key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\XYZ"
Value="DisplayName"/>
</InstallChecks>
<Commands>
<Command PackageFile="XYZ.exe" Arguments="/Install">
<InstallConditions>
<BypassIf Property="IS_XYZ_INSTALLED"
Compare="ValueEqualTo" Value="XYZ2.1_rc22"/> // tHIS IS THE DISPLAYNAME, THAT I SEE IN …Run Code Online (Sandbox Code Playgroud) 我是Android的新手.
我想开发一个应用程序,我可以根据所选按钮更改屏幕.应用程序最终可能会有20多个带按钮或输入表格的屏幕.从1个屏幕我开始将屏幕更改为其他屏幕.我想到了FrameLayout我可以改变孩子的地方.
我没有办法启动.就像我创建了一个Activity.我的每个屏幕应该超过哪个类,所以我可以将它添加到布局?如何在启动时显示第一个屏幕.
这些似乎都是简单而愚蠢的问题,但实际上我无法得到相同的起点.任何帮助都是为了帮助我实现目标.
更新 :
@Ghost,从你的解决方案中我想到了另外一个问题.对于我只需要以特定格式显示按钮的屏幕,我在此站点的帮助下添加了一个GridView和一个ButtonAdapter .
如果我只在ButtonAdapter中添加clickListener,那么如何将参数传递给setIntent(FooFooActivity.this ....)????? 我在ButtonAdapter中有Conext - 我可以将它强制转换为FooFooActivity,并且可以继续使用它.我可以在onclick()的ButtonAdapter中给出ifs以使其进入正确的屏幕.但是setIntent cna就像我说的那样或类似的东西.如果它可以工作,那么对于许多屏幕,我的单个GridView和单个ButtonAdapter类可以完成所有工作.
试验新的最新进展:
@Ghost,我试过,发现ButtonAdapter中的上述setIntent(FooFooActivity.this ....)不起作用 - 就像在ButtonAdapter中一样,它找不到FooFooActivity.this的范围.
要在多个活动中使用相同的buttonspage.xml布局,我将FooFooActivity的内容设置为buttonspage并设置其按钮单击侦听器.对于1按钮,我设置退出应用程序,而其他按钮显示DataActivity.
因此,我得到了2个活动,FooFoo显示返回FooFoo的DataActivity/Exit和DataActivity.它是一个以FoofooActivity开始和结束的循环.如果我先点击"退出",它会退出.但是如果在显示DataActivity后单击"退出",则它只是不退出并仅显示DataActivity.是不是我不能在多个活动中使用相同的布局?或者我可能在某个地方出错(我对此表示怀疑)?相同的按钮页面布局我在10-12页中使用,除了在按钮和事件上有不同的文本.所以一直在考虑写一次使用多次.还必须动态更改所有这些页面按钮的按钮样式.
谢谢