我想使用某些动画,例如在画布中弹跳.是否可以在里面使用动画插值器?
在我的情况下,我想将图像从0度旋转到180度,最后反弹.
这怎么可能?
我正在尝试在android中开发一个应用程序,它包含一个服务来读取传感器值多个小时.当我启动服务时,我的设备会挂起,所有其他进程都会变慢.为了解决这个问题,我尝试在单独的线程中启动服务,如下所示,但问题仍然存在.
new Thread(new Runnable() {
@Override
public void run() {
Intent intent=new Intent(getApplicationContext(), SensorService.class);
startService(intent);
}
}).start();
Run Code Online (Sandbox Code Playgroud)
此线程仅在不同的线程中启动服务,但服务在主线程中运行.Plz有人帮我如何在单独的线程中运行服务?
您好,Google Tasks API团队,
从几天前开始,我们已经开始"403 Forbidden"为很多用户提供服务.
你能检查一下发生了什么吗?我们的API控制台很干净,#calls方式如下.
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Serving Limit Exceeded",
"reason" : "serviceLimit"
} ],
"message" : "Serving Limit Exceeded"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145) ~[google-api-client-1.15.0-rc.jar:1.15.0-rc]
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:111) ~[google-api-client-1.15.0-rc.jar:1.15.0-rc]
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:38) ~[google-api-client-1.15.0-rc.jar:1.15.0-rc]
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312) ~[google-api-client-1.15.0-rc.jar:1.15.0-rc]
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1042) ~[google-http-client-1.15.0-rc.jar:na]
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410) ~[google-api-client-1.15.0-rc.jar:1.15.0-rc]
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343) ~[google-api-client-1.15.0-rc.jar:1.15.0-rc]
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460) ~[google-api-client-1.15.0-rc.jar:1.15.0-rc]
Run Code Online (Sandbox Code Playgroud) 我想了解它的adb shell setprop mypropertykey mypropertyvalue工作原理.换句话说,我编辑了/system/build.prop文件,但是当我尝试使用getprop命令来读取值时,我似乎得到了一个空值.
但是,当我adb shell setprop在root模式下设置属性然后取消模拟器并使用代码读取值时,我能够获得正确的值.
我不明白的是,如果通过设置值设置adb shell setprop为什么它不会被写入build.prop文件?那么从哪里getprop读取值?
我想将反弹动画应用到我的文本中.有可能吗?如果是的话,你能告诉我怎么样吗?谢谢.
我想拉伸图像以填充宽度并根据宽度调整高度并保持纵横比.我希望它应该覆盖整个宽度(fillparent)和imageview的高度应该像方式调整,以保持纵横比.
我试过fit_xy,但不适用于我的情况.请帮我
我试图比较两个ArrayLists,并且在比较之后我必须得到这两个arraylists之间的共同元素并在第三个arraylist中显示它们.
这是我的代码,这里newList是我想要添加公共元素的arraylist,但每次我在这个arraylist中添加元素时它只显示最后一个元素.
ArrayList<String> list2 = new ArrayList<String>();
list2.add("1");
list2.add("abc");
list2.add("3");
list2.add("4");
ArrayList<String> list1 = new ArrayList<String>();
list1.add("3");
list1.add("4"); list1.add("7");
list1.add("8");
list1.add("12");
list1.add("4");
list1.add("53");
list1.add("2");
list1.add("62");
list1.add("abc");
System.out.println("btn click r_answer "+list1+" "+list2);
for (int i=0;i<list1.size();i++) {
for (int j=0;j<list2.size(); j++) {
if(list1.get(i).equals(list2.get(j)))
System.out.println("equals..:"+list2.get(j));
newList.add(list2.get(j));
}
}
Run Code Online (Sandbox Code Playgroud) 可展开的Listview SetIndicatorBounds在我的项目代码中不起作用.
这是我的布局:
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|center_vertical"
android:weightSum="1.0"
>
<ExpandableListView
android:id="@+id/custom_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:dividerHeight="1dp"
android:layout_weight="1"
android:paddingBottom="0dp"
android:divider="#b5b5b5"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
lv1 = (ExpandableListView) findViewById(R.id.custom_list);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
lv1.setIndicatorBounds(width - GetPixelFromDips(50), width - GetPixelFromDips(10));
public int GetPixelFromDips(float pixels) {
// Get the screen's density scale
final float scale = getResources().getDisplayMetrics().density;
// Convert the dps to pixels, based on density scale
return (int) (pixels * scale + 0.5f);
}
Run Code Online (Sandbox Code Playgroud)
我的Moto G kitkat设备宽度为720.但是setIndicatorBounds似乎没有在我的Kitkat设备中解决.
任何帮助将不胜感激.
谢谢,
我正在尝试在 PrestaShop 中调用网络服务,但出现 401 未授权错误。即使我已经通过了用户名密钥。我也尝试了身份验证器,但出现错误 HttpRetryingError。
在下面找到我所做的代码片段。
方法一:
final String username = "key_here";
final String password = "";// leave it empty
URL urlToRequest = new URL(urlStr);
urlConnection = (HttpURLConnection) urlToRequest.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("GET");
urlConnection.setRequestProperty("Content-Type",
"text/xml;charset=utf-8");
String authToBytes = username + ":" + password;
//....
byte[] authBytes = org.apache.commons.codec.binary.Base64.encodeBase64(authToBytes.getBytes());
String authBytesString = new String(authBytes);
//then your code
urlConnection.setRequestProperty("Authorization","Basic " + authBytesString);
int statusCode = urlConnection.getResponseCode(); ---> i get 401
if (statusCode != HttpURLConnection.HTTP_OK) {
// throw some exception
InputStream in =
new …Run Code Online (Sandbox Code Playgroud) 我正在使用ABS.我的发射器活动是RegistrationActivity.当我扩展它时SherlockActivity,我的应用程序工作正常.但是当我扩展它时SherlockFragmentActivity,我的应用程序在我的手机上运行时崩溃了.
package com.example.app;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.support.v4.app.DialogFragment;
import com.actionbarsherlock.app.SherlockFragmentActivity;
public class RegistrationActivity extends SherlockFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Check if the user is already registered
Context context = this;
SharedPreferences settings = context.getSharedPreferences( "settings" , Context.MODE_PRIVATE);
int isRegistered = settings.getInt( "isRegistered", 0 );
if( isRegistered == 1 ) {
Intent intent = new Intent(this, DashboardActivity.class);
startActivity(intent);
}
else { …Run Code Online (Sandbox Code Playgroud) 我目前正在学习如何在android中使用Jaxb解析xml文件.但我不知道代码中有什么问题,以及在何处以及如何纠正它.我无法解析xml并获取食物清单.如果我删除List并简单地将其写为Food,那么只解析xml中的最后一个元素,其余部分似乎被覆盖.请帮我.
我正在尝试解析http://www.w3schools.com/xml/simple.xml,到目前为止我有这个代码:
----用于解析XML的代码
URL url = new URL("http://www.w3schools.com/xml/simple.xml");
InputSource is = new InputSource(url.openStream());
is.setEncoding("ISO-8859-1");
JAXBContext jaxbContext = JAXBContext.newInstance(BreakfastMenu.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
BreakfastMenu menu = (BreakfastMenu)jaxbUnmarshaller.unmarshal(is);
Run Code Online (Sandbox Code Playgroud)
-----这些类看起来像----- Breakfast.java
@XmlRootElement(name="breakfast_menu")
public class BreakfastMenu {
private List<Food> food = new ArrayList<Food>();
public List<Food> getFood() {
return food;
}
@XmlElement(name="food")
public void setFood(List<Food> food) {
this.food = food;
}
Run Code Online (Sandbox Code Playgroud)
}
---食品类
@XmlRootElement(name="food")
public class Food {
private String name;
private String description;
private String calories;
public String getName() {
return name; …Run Code Online (Sandbox Code Playgroud) 毕竟我已经设法"准备"我的NDK日食(至少我认为如此),它不再在c代码争论,但现在我得到"没有找到本机Lcom的实现"任何时候我执行任何本机代码.它也发生在NDK的样品上..
我的.java
...
private native float pi();
static
{
System.loadLibrary("shit");
}
...
System.out.println(pi());
...
Run Code Online (Sandbox Code Playgroud)
我的.cpp
#include <jni.h>
jfloat Java_com_example_shit_MainActivity_pi(JNIEnv * env, jobject obj) {
return 3.1415;
}
Run Code Online (Sandbox Code Playgroud)
我的.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := shit
LOCAL_SRC_FILES := shit.cpp
include $(BUILD_SHARED_LIBRARY)
Run Code Online (Sandbox Code Playgroud)
我的错误日志
11-14 18:30:16.231: D/dalvikvm(1739): Trying to load lib /data/data/com.example.shit/lib/libshit.so 0x413b1fc8
11-14 18:30:16.241: D/dalvikvm(1739): Added shared lib /data/data/com.example.shit/lib/libshit.so 0x413b1fc8
11-14 18:30:16.241: D/dalvikvm(1739): No JNI_OnLoad found in /data/data/com.example.shit/lib/libshit.so 0x413b1fc8, skipping init
11-14 18:30:16.271: D/TextLayoutCache(1739): Using debug level: 0 - Debug …Run Code Online (Sandbox Code Playgroud) 我的代码:
if(!"".equals(et1.getText().toString())){
Toast.makeText(getActivity(), "Please enter text1", Toast.LENGTH_SHORT).show();
} else if(!"".equals(et2.getText().toString())){
Toast.makeText(getActivity(), "Please enter text2", Toast.LENGTH_SHORT).show();
} else if(!"".equals(et3.getText().toString())){
Toast.makeText(getActivity(), "Please enter text3", Toast.LENGTH_SHORT).show();
} else if(!"".equals(et4.getText().toString())){
Toast.makeText(getActivity(), "Please enter text4", Toast.LENGTH_SHORT).show();
} else if(!"".equals(et5.getText().toString())){
Toast.makeText(getActivity(), "Please enter text5", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
//总共13个字段,所以这将接近13个检查.所以我想知道是否有可能检查一个语句并找到哪个字段留空.
谢谢.
android ×12
java ×4
adb ×1
android-ndk ×1
aspect-ratio ×1
c++ ×1
for-loop ×1
getproperty ×1
google-api ×1
google-tasks ×1
if-statement ×1
jaxb ×1
listview ×1
prestashop ×1
web-services ×1
xml ×1