Giter Site home page Giter Site logo

Comments (10)

JakeWharton avatar JakeWharton commented on August 24, 2024 2

This works for me:

public final class CustomView extends TextView {
  public CustomView(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (isInEditMode()) {
      AndroidThreeTen.init(context);
      setText("Test: " + LocalDateTime.now());
    }
  }
}
<?xml version="1.0" encoding="utf-8"?>
<com.example.CustomView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

screen shot 2019-01-23 at 11 56 35 am

from threetenabp.

kotucz avatar kotucz commented on August 24, 2024

You can avoid using now() in edit mode. You probably can work with fixed data for preview

from threetenabp.

AndreasBackx avatar AndreasBackx commented on August 24, 2024

@kotucz yes, that's what I did. but I still reported it just in case.

from threetenabp.

JakeWharton avatar JakeWharton commented on August 24, 2024

I think you would have to declare the dependency as apk and then declare regular ThreeTenBP as compileOnly. Not sure what classpath layoutlib uses.

from threetenabp.

JakeWharton avatar JakeWharton commented on August 24, 2024

Of course that would also prevent referencing our init...

from threetenabp.

AndreasBackx avatar AndreasBackx commented on August 24, 2024

Unfortunately I am no longer working on the project so I cannot take it for a spin. Do you have any idea why this error occurs in the edit mode?

from threetenabp.

JakeWharton avatar JakeWharton commented on August 24, 2024

from threetenabp.

JakeWharton avatar JakeWharton commented on August 24, 2024

I have upstreamed this as a feature request to support asset loading in layoutlib: https://issuetracker.google.com/issues/78324332.

from threetenabp.

AndreasBackx avatar AndreasBackx commented on August 24, 2024

Great, I'll try to keep an eye on it. Thanks for filing the feature request.

from threetenabp.

AndreasBackx avatar AndreasBackx commented on August 24, 2024

Thanks! I'll keep it in mind for future projects. I appreciate you reporting back.

from threetenabp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.