我有一个Recycler视图,它位于SwipeRefreshLayout内部.此外,还可以打开另一个活动中的每个项目.返回Recycler后,我需要滚动到所选项目,或者前一个Y.如何做到这一点?
是的,我用Google搜索,在StackOverFlow中找到关于保存布局管理器实例的文章,如下所示:RecyclerView在活动之间存储/恢复状态.但是,它对我没有帮助.
UPDATE
现在我有这种解决问题,当然,它也没有用.
private int scrollPosition;
...//onViewCreated - it is fragment
recyclerView.setHasFixedSize(true);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(llm);
data = new ArrayList<>();
adapter.setData(getActivity(), data);
recyclerView.setAdapter(adapter);
...
@Override
public void onResume() {
    super.onResume();
    recyclerView.setScrollY(scrollPosition);
}
@Override
public void onPause() {
    super.onPause();
    scrollPosition = recyclerView.getScrollY();
}
Run Code Online (Sandbox Code Playgroud)
是的,我尝试过scrollTo(int,int) - 不行.
现在我尝试滚动,例如,Y = 100,但它根本不滚动.
Android项目中的检测测试存在问题:它们从“项目结构”窗口调用No tests found时正在运行,但是从编辑器的绿色箭头运行时却正在运行。我想他们正在作为单元测试运行。
有趣的是,Java项目对此没有任何问题。而且,如果我在OS Windows或MacOS上运行仪器化测试-一切都很好,但在Ubuntu中却没有。
Kotlin插件版本为1.2.21。Gradle版本为3.0.1。
我使用配置类创建了Spring Boot应用程序.通常使用Spring库的RestAPI.在其中我使用我自己的Logger类来记录每个动作.
另外,我在我的Application类中包含application.properties,其中是main函数.xml中没有bean - 仅在该Configuration类中的所有内容.
这是配置:
@SpringBootConfiguration
public class ApplicationConfiguration {
@Value("${hibernate.dialect}")
private String dialect;
@Value("${hibernate.show_sql}")
private String showSql;
@Value("${hibernate.mappingResources}")
private String[] mappingResources;
@Value("${jdbc.driverClassName}")
private String driverClassName;
@Value("${jdbc.url}")
private String url;
@Value("${jdbc.username}")
private String username;
@Value("${jdbc.password}")
private String password;
@Autowired
private DataSource dataSource;
@Autowired
private LocalSessionFactoryBean localSessionFactoryBean;
@Bean
public LocalSessionFactoryBean localSessionFactoryBean() {
    LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
    sessionFactoryBean.setDataSource(dataSource);
    Properties hibernateProperties = new Properties();
    hibernateProperties.setProperty("hibernate.dialect", dialect);
    hibernateProperties.setProperty("hibernate.show_sql", showSql);
    sessionFactoryBean.setHibernateProperties(hibernateProperties);
    sessionFactoryBean.setMappingResources(mappingResources);
    return sessionFactoryBean;
}
@Bean
public DataSource dataSource() {
    DriverManagerDataSource dataSource = …Run Code Online (Sandbox Code Playgroud)