我正在尝试使用动画来使布局显示在屏幕上.我们的想法是布局将从0开始,并增长到100%.
我真的遇到了麻烦,需要一些帮助.由于某种原因,不执行动画.
这是我的动画XML文件
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXScale="0.0"
android:toXScale="1"
android:fromYScale="1.0"
android:toYScale="1.0"
android:fillAfter="false"
/>
</set>
Run Code Online (Sandbox Code Playgroud)
布局文件非常基本,设计如下
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/dialog"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:layout_centerVertical="true"
android:background="@drawable/border">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Phone"
android:id="@+id/textView"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Address"
android:id="@+id/textView1"/>
<Button android:id="@+id/btn1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Action 1"
/>
<Button android:id="@+id/btn2"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Action 2"
/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Animate"
android:id="@+id/btnAnimate" android:layout_alignParentLeft="true" android:layout_alignParentTop="true"
android:onClick="animate"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的活动代码也非常基础
public class MyActivity extends Activity implements Animation.AnimationListener{
@Override
public void …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个passwordDigest util,它可以在能够运行java字节代码的不同环境中使用.
首先,我创建了nonce.它是这样完成的.
public static String buildNonce(){
StringBuffer nonce=new StringBuffer();
String dateTimeString = Long.toString(new Date().getTime());
byte[] nonceByte= dateTimeString.getBytes();
return Base64.encode(nonceByte);
}
Run Code Online (Sandbox Code Playgroud)
一旦我有了nonce,我就构建了密码摘要.
public static String buildPasswordDigest(String userName, String password, String nonce, String dateTime){
MessageDigest sha1;
String passwordDigest=null;
try {
sha1= MessageDigest.getInstance("SHA-1");
byte[] hash = MessageDigest.getInstance("SHA-1").digest(password.getBytes("UTF-8"));
sha1.update(nonce.getBytes("UTF-8"));
sha1.update(dateTime.getBytes("UTF-8"));
passwordDigest = new String(Base64.encode(sha1.digest(hash)));
sha1.reset();
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return passwordDigest;
Run Code Online (Sandbox Code Playgroud)
为了测试一切正常.我使用CXF 2.7创建了一个测试Web服务.我手动创建了SOAP Envelope来测试身份验证.信封看起来像这样.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ws="http://ws.mytest.org/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> …Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何使用反射。我设置了2个班级,其中一个对数字进行了基本验证
public class Reflectee {
String str;
public Reflectee(String str){
this.str=str;
}
public Reflectee(){
}
public boolean doSomething(String str){
boolean flag=true;
try{
Integer.parseInt(str);
}catch (NumberFormatException e){
flag=false;
}
return flag;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我创建了一个类,该类将使用反射来调用doSomething方法。
public class Reflector {
private String str="22";
public boolean reflect(){
Reflectee r=new Reflectee();
Class clazz=r.getClass();
boolean b=false;
try {
Method m=clazz.getDeclaredMethod("doSomething",String.class);
b=(Boolean)m.invoke(this,str); //Exception is here
} catch (NoSuchMethodException | SecurityException |
IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return b; …Run Code Online (Sandbox Code Playgroud) 我们公司购买了一个用.NET编写的应用程序,我很荣幸能够支持它.我从未使用过.NET,因此我需要一些有关如何使用lambda的指导.
在我的cshtml文件中,我试图获取一个值并验证它是否为NULL.
我试过这样做
var appointment = x => x.AppointmentDate;
Run Code Online (Sandbox Code Playgroud)
我收到编译器错误" 无法将lambda表达式赋值给隐式类型的局部变量 ".我用Google搜索了错误并尝试了以下内容.
Func<DateTime, DateTime> appointment = x => x.AppointmentDate;
Run Code Online (Sandbox Code Playgroud)
但是现在编译器给出了这个错误" 'System.DateTime'不包含'AppointmentDate'的定义,并且没有可以找到接受类型'System.DateTime'的第一个参数的扩展方法'AppointmentDate'(你是否缺少using指令或装配参考?) "
如何从lambda获取验证值?