我尝试使用新的Granular Dependency for Google Play Service 6.5.+
在我的gradle我设置:
dependencies {
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.google.maps.android:android-maps-utils:0.3'
compile 'com.google.android.gms:play-services-base:6.5.87'
compile 'com.google.android.gms:play-services-location:6.5.87'
compile 'com.google.android.gms:play-services-maps:6.5.87'
}
Run Code Online (Sandbox Code Playgroud)
但是我收回了这个错误:
Error:Execution failed for task ':app:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms'
You can temporarily disable this error with android.enforceUniquePackageName=false
However, this is temporary and will be enforced in 1.0
Run Code Online (Sandbox Code Playgroud)
我已经更新了所有SDK.
使用这个新功能的正确方法是什么?谢谢.
解决了
问题是android-maps-utils已经有Play Service 6.5.+,所以错误.
在我的应用程序中,我以这种方式创建了一个新的目录;
File mydir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "/my_directory");
if (!mydir.exists()) {
mydir.mkdirs();
}
Run Code Online (Sandbox Code Playgroud)
它运作良好,但Android Studio(0.8.9)只是继续向我报告此警告:
"File.mkdirs()"的结果被忽略
谁能解释我为什么?谢谢.
我有三个文件:
{
"id_user": "t57092501745ad6285ac58c22",
"name": "Day #1",
"date": {
"$date": "2016-04-21T20:50:00.190Z"
},
"text": "My text"
}
{
"id_user": "t57092501745ad6285ac58c22",
"name": "Day #2",
"date": {
"$date": "2016-04-22T20:50:00.190Z"
},
"text": "My text"
}
{
"id_user": "t57092501745ad6285ac58c22",
"name": "Day #3",
"date": {
"$date": "2016-04-22T20:51:00.190Z"
},
"text": "My text"
}
Run Code Online (Sandbox Code Playgroud)
我需要将这些分组为一天,所以我这样做:
{
"$match": {
"id_user": "t57092501745ad6285ac58c22"
}
}, {
"$sort": {
"date": -1
}
}, {
"$group": {
"_id": {
$dayOfYear: "$date"
},
"data": {
"$push": {
"id_user": "$id_user",
"name": "$name",
"date": "$date",
"text": …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用ObjectAnimator向下移动ImageView.setDuration()方法似乎不会影响动画的持续时间.我不能在XML中设置这个动画,因为我想动态地播放它.
ObjectAnimator an= ObjectAnimator.ofFloat(img, View.TRANSLATION_Y, 0, 100);
an.setDuration(5000);
an.start();
Run Code Online (Sandbox Code Playgroud)
在这里对主题进行排序,但是说我想在彼此之后玩多个ObjectAnimation,有没有办法做到这一点?我看过Animator集,但我不确定它是否会像Object Animator一样移动实际对象,而不是像TranslateAnimation那样出现.
提前致谢!
我构建了一个类(例如一个类来制作简单的动画):
public class myAnimations {
private Animation animation;
private ImageView imageView;
public myAnimations(ImageView img) {
super();
this.imageView = img;
}
public void rotate(int duration, int repeat) {
animation = new RotateAnimation(0.0f, 360.0f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
animation.setRepeatCount(repeat);
animation.setDuration(duration);
}
public void play() {
imageView.startAnimation(animation);
}
public void stop() {
animation.setRepeatCount(0);
}
}
Run Code Online (Sandbox Code Playgroud)
我只是可以这样使用它:
ImageView myImage = (ImageView) findViewById(R.id.my_image);
myAnimations animation = new myAnimations(myImage);
animation.rotate(1000, 10);
animation.play(); //from this way…
Run Code Online (Sandbox Code Playgroud)
但如果我想能够像这样使用它:
ImageView myImage = (ImageView) findViewById(R.id.my_image);
myAnimations animation = …
Run Code Online (Sandbox Code Playgroud) 我需要帮助解析String
日期
"Thu Oct 22 13:51:51 CEST 2015"
Run Code Online (Sandbox Code Playgroud)
有SimpleDateFormat
,但我无法找到正确的模式.
这是我尝试过的
String date = "Thu Oct 22 13:51:51 CEST 2015";
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("E M d H:m:s z y");
d1 = dateFormat.parse(date);
} catch (ParseException e1) {
Log.e(null, String.valueOf(e1));
}
Run Code Online (Sandbox Code Playgroud)
我收回错误:
java.text.ParseException: Unparseable date: "Thu Oct 22 13:51:51 CEST 2015" (at offset 0)
Run Code Online (Sandbox Code Playgroud)
UPDATE
我尝试了durron597下面的解决方案,使其适应我的需求:
String date = "Thu Oct 22 13:51:51 CEST 2015";
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("E MMM dd HH:mm:ss zzzz …
Run Code Online (Sandbox Code Playgroud) 好吧,我需要裁剪特定形状的ImageView,我不能通过添加png来实现这一点,因为背景可以变化(例如模式).所以,我需要形状外的区域是透明的.
形状必须是这样的:
我想用Path()来绘制这个形状并使用它来掩盖ImageView,但我完全不知道如何使用Path()绘制这样的复杂形状.
非常感谢.