如何使用Tab布局与数据绑定库和Kotlin

时间:2018-01-22 16:21:56

标签: android kotlin android-tablayout android-databinding

我试图在Kotlin项目中使用Tab Layout + Android数据绑定库,但我没有成功。

请告诉我我做错了什么?

这是我的活动:

private String configFilePath;

    private Optional<ItemMasterFileProcessorConfiguration> config;

    public ItemMasterFileProcessorTaskModule(String configFilePath)
    {
        this.configFilePath = configFilePath;
        config = Optional.empty();
    }

    @Override
    public void configure(Binder binder)
    {
        binder.bind(<Interface>.class).to(<ImplClass>.class);
        binder.bind(<Interface>.class).to(<ImplClass>.class);
    }

    @Provides
    public ItemMasterFileProcessorConfiguration getConfig() throws ItemMasterFileProcessorException
    {
        Yaml yaml = new Yaml();

        try
        {
            if (!config.isPresent())
            {
                ItemMasterFileProcessorConfiguration writerConfig = yaml.loadAs(ItemMasterFileProcessorConfiguration.class.getClassLoader().getResourceAsStream(configFilePath), ItemMasterFileProcessorConfiguration.class);
                config = Optional.of(writerConfig);
            }
            /*
             * Sonar is wanting is to add isPresent() before this But if I do
             * Sonar complains that it will always evaluate to TRUE
             */
            return config.get();
        }
        catch (Exception e)
        {
            throw new ItemMasterFileProcessorException("Config is NULL while initializing configuration for config path : {}", e);
        }
    }

这是最终结果:没有触摸效果的空标签 enter image description here

0 个答案:

没有答案