我基于创建列表和卡片指南创建了RecyclerView示例.我的适配器只有一个模式实现来扩展布局.
问题是滚动性能差.这在RecycleView中只有8个项目.
在一些测试中我验证了在Android L中没有出现这个问题.但在KitKat版本中,性能的下降是显而易见的.
java performance android recycler-adapter android-recyclerview
根据Google Design Guidelines,我需要在API级别为19的Android应用程序上实现一个浮动操作按钮.
但是,我会知道是否有一些原生支持库(如v4,v7,v13)来帮助我构建这个组件而不需要外部依赖.
我有一个多模块Maven项目(https://github.com/veniltonjr/msplearning)
我需要的一个模块我需要以编程方式从Maven构建"clean install " 命令,但是当我调用这些目标的执行时,会发生以下错误:
java.lang.IllegalStateException: 未指定Maven应用程序目录,系统属性中未提供$ {maven.home}.请至少详细说明.
在Maven Invoker文档中说M2_HOME环境变量必须存在.
已经在我的SO中设置了这个变量.这不足以使该方法invoke有效吗?按照我运行相关方法的代码片段:
Invoker invoker = new DefaultInvoker();
invoker.setLocalRepositoryDirectory(new File("C:\\git\\msplearning"));
InvocationRequest request = new DefaultInvocationRequest();
request.setGoals(Arrays.asList("clean", "install"));
InvocationResult result = invoker.execute(request); // Exception occours here...
Run Code Online (Sandbox Code Playgroud)
已经,谢谢!
编辑(解决方案)
我必须设置POM并设置Maven Home,在我的例子中是在M3_HOME环境变量中:
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(new File("C:\\git\\msplearning\\pom.xml"));
request.setGoals(Collections.singletonList("verify"));
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(new File(System.getenv("M3_HOME")));
InvocationResult result = invoker.execute(request);
Run Code Online (Sandbox Code Playgroud)
谢谢@RobertScholte和@khmarbaise!
我实现了一个SwipeRefreshLayout使用a RecyclerView,我需要在我期间禁用我的适配器项OnRefreshListener.
我尝试了以下方法,但点击正常发生:
mRecyclerView.setEnabled(false);
mRecyclerView.setClickable(false);
Run Code Online (Sandbox Code Playgroud) java android android-support-library swiperefreshlayout android-recyclerview
我正在尝试在Android应用程序中使用REST服务,但在序列化ArrayList时遇到问题:
我的RESTful服务返回:

我的Android应用程序收到:

我正在使用Gson库来序列化我的对象,当然问题与它有关.从这个意义上讲,我尝试按如下方式制作Serializer:
public class MySerializer<E>
implements JsonSerializer<Collection<E>>, JsonDeserializer<Collection<E>> {
@Override
public Collection<E> deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
Type type = new TypeToken<List<E>>(){}.getType();
return context.deserialize(json, type);
}
@Override
public JsonElement serialize(Collection<E> src, Type typeOfSrc,
JsonSerializationContext context) {
Type type = new TypeToken<List<E>>(){}.getType();
return context.serialize(src, type);
}
}
Run Code Online (Sandbox Code Playgroud)
注册apapter(registerTypeAdapter(ArrayList.class, new MySerializer<Object>())),但这不起作用......
有人可以帮帮我吗?
我最近迁移了一个项目的Spring Boot版本,从1.X版本升级到2.X版本。但是,这会导致使用org.bson.Document(using PojoCodecProvider)恢复持久对象时出现问题,因为它们没有该_class字段。
我按如下方式保留我的信息(我需要保存我的所有实例以便以后检索它们):
Map<String, Object> outbound = new HashMap<>();
// Add multiple objects/instances of different types
log.setOutbound(new Document(outbound));
Run Code Online (Sandbox Code Playgroud)
我的Log实体/文档基本上是这样的:
public class Log {
private ObjectId id;
private Document outbound;
// Getters ans Setters
}
Run Code Online (Sandbox Code Playgroud)
当我尝试恢复持久化对象并转换为它们的特定类型时会出现问题:
Log log = this.logRepository.findById("ID_HERE");
Document outbound = lastTracking.getOutbound();
MyType = outbound.get("myTypeKey", MyType.class); //A cast exception occours here!
Run Code Online (Sandbox Code Playgroud)
分析 Spring Boot 版本 1 和 2 中保存的数据之间的差异,我发现最新版本停止记录_class字段,查找存储在我的Document( Log#outbound) 中的实例。
有没有人遇到过这个问题?非常感谢您提前!
更新:我创建了一个模拟这个问题的简单存储库:
https://github.com/falvojr/stackoverflow-61560293
的 …
我有一个Android应用程序(Spring Android + Android Annotations + Gson),它使用来自Web应用程序(Jersey + Spring + Hibernate/JPA)的REST服务.问题是我的java.util.Date属性没有序列化:
活动(Android应用程序):
...
@Click(R.id.buttonLogin)
void onLoginClick() {
Student student = new Student();
student.setDateRegistration(new Date()); //Property where the problem occurs
student.setFirstName("Venilton");
student.setGender(Gender.M);
doSomethingInBackground(student);
}
@Background
void doSomethingInBackground(Student student) {
this.restClient.insert(student);
}
...
Run Code Online (Sandbox Code Playgroud)
休息客户端(Android应用程序):
@Rest(rootUrl = "http://MY_IP:8080/restful-app",
converters = { GsonHttpMessageConverter.class })
public interface StudentRESTfulClient {
@Post("/student/insert")
Student insert(Student student);
}
Run Code Online (Sandbox Code Playgroud)
Rest Server(Web App):
@Component
@Path("/student")
public class StudentRESTfulServer {
@Autowired
private StudentService studentServiceJpa;
@POST
@Path("/insert")
public Student insert(Student student) {
//student.getDateRegistration() …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的项目中配置库v7支持,以便它使用ActionBarActivity,从而保持与某些Android 2.X版本的兼容性.
首先,按照从谷歌文档和导入项目android-support-v7-appcompat,如按照第一个库添加具有资源库的支持库设置.但是这样我的Maven Build失败了,因为它找不到相关库的依赖性.
现在,我决定寻求一个更清洁的解决方案,让我的依赖由Maven管理.为此,请按照答案的说明进行操作,但使用的是版本19.0.1.这使我的Maven Build成功执行,但我的项目没有在我的工作区编译,在我的POM的第一行发生以下错误:
dependency=[com.android.support:appcompat-v7:apklib:19.0.1:compile]not found in workspace
Run Code Online (Sandbox Code Playgroud)
我的依赖关系如下:
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>${com.android.support-version}</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>${com.android.support-version}</version>
<type>jar</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)
有问题的项目在GitHub上,如果他们想查看它:https://github.com/veniltonjr/msplearning
先感谢您!
java ×7
android ×6
gson ×2
rest ×2
bson ×1
maven ×1
performance ×1
spring-boot ×1
spring-data ×1