如在Android Studio 3.0(canary 3.0)中所见,我们现在depedencies
通过声明implementation
而不是compile
配置来添加.
// Before
compile 'com.android.support:appcompat-v7:25.3.1'
// Currently
implementation 'com.android.support:appcompat-v7:25.3.1'
Run Code Online (Sandbox Code Playgroud)
我们仍然可以使用compile
,但我想了解:
implementation
和compile
配置有什么区别?implementation
用作默认值?我正在尝试使用新的架构组件,但我还是匕首的新手,而且我缺少了东西.
使用下面的代码,我得到一个NullPointerException,找不到位置.如果还有其他我需要修复或改进的地方,请建议.
代码: ViewModel
public class PostsVM extends ViewModel {
private LiveData<StoryPost> post;
private Repository repository;
@Inject
public PostsVM(Repository repository) {
this.repository = repository;
}
public void init() {
if (this.post != null) {
return;
}
post = repository.getPosts();
}
public LiveData<StoryPost> getPost() {
return post;
}
}
Run Code Online (Sandbox Code Playgroud)
知识库
@Singleton
public class Repository {
private final MutableLiveData<StoryPost> data = new MutableLiveData<>();
public LiveData<StoryPost> getPosts() {
//
new GetUser(post.getUid()) {
@Override
public void onSuccess(@NonNull User user) {
// this is where …
Run Code Online (Sandbox Code Playgroud) java android model-view dagger-2 android-architecture-components
我尝试了以下查询,但没有给出任何结果。
SELECT * FROM details WHERE name LIKE :name
我使用 AutoCompleteTextview 进行搜索。有什么查询可以用子字符串查找吗?
android ×2
android-architecture-components ×1
android-room ×1
dagger-2 ×1
gradle ×1
java ×1
model-view ×1