- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
几乎完成了这个应用程序,并在我的 Movie
类中遇到了数据绑定(bind)方面的编译时错误,我扩展了 BaseObserver
并在尝试构建项目时我可以' t 为 notifyPropertyChanged(BR.voteCount);
导入 BR 在二传手上。我看不到这个问题,但如果我尝试编译并且它通过了,它会在启动时崩溃并显示以下堆栈跟踪。
我想如果是生成的代码有问题,那么我该如何解决呢???
真的很困惑!任何帮助表示赞赏。
我添加了依赖项,看不到任何问题......
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
dataBinding {
enabled = true
}
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.tmdbclient"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
def lifecycle_version = "2.0.0"
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
// alternatively - just ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version" // For Kotlin use lifecycle-viewmodel-ktx
annotationProcessor 'com.android.databinding:compiler:2.3.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation 'com.android.support:cardview-v7:29.0.0'
implementation 'com.android.support:recyclerview-v7:29.0.0'
implementation 'com.android.support:design:29.0.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
}
<小时/>
型号
package com.example.tmdbclient.model;
import android.os.Parcel;
import android.os.Parcelable;
import android.widget.ImageView;
import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;
import androidx.databinding.BindingAdapter;
import androidx.databinding.BR;
import com.bumptech.glide.Glide;
import com.example.tmdbclient.R;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
public class Movie extends BaseObservable implements Parcelable
{
@SerializedName("vote_count")
@Expose
private Integer voteCount;
@SerializedName("id")
@Expose
private Integer id;
@SerializedName("video")
@Expose
private Boolean video;
@SerializedName("vote_average")
@Expose
private Double voteAverage;
@SerializedName("title")
@Expose
private String title;
@SerializedName("popularity")
@Expose
private Double popularity;
@SerializedName("poster_path")
@Expose
private String posterPath;
@BindingAdapter("posterPath")
public void loadImage(ImageView imageView, String imageURL) {
String imagePath = "https://image.tmdb.org/t/p/w500" + imageURL;
Glide.with(imageView.getContext())
.load(imagePath)
.placeholder(R.drawable.loading)
.into(imageView);
}
@SerializedName("original_language")
@Expose
private String originalLanguage;
@SerializedName("original_title")
@Expose
private String originalTitle;
@SerializedName("genre_ids")
@Expose
private List<Integer> genreIds = new ArrayList<Integer>();
@SerializedName("backdrop_path")
@Expose
private String backdropPath;
@SerializedName("adult")
@Expose
private Boolean adult;
@SerializedName("overview")
@Expose
private String overview;
@SerializedName("release_date")
@Expose
private String releaseDate;
public final static Parcelable.Creator<Movie> CREATOR = new Creator<Movie>() {
@SuppressWarnings({
"unchecked"
})
public Movie createFromParcel(Parcel in) {
return new Movie(in);
}
public Movie[] newArray(int size) {
return (new Movie[size]);
}
}
;
protected Movie(Parcel in) {
this.voteCount = ((Integer) in.readValue((Integer.class.getClassLoader())));
this.id = ((Integer) in.readValue((Integer.class.getClassLoader())));
this.video = ((Boolean) in.readValue((Boolean.class.getClassLoader())));
this.voteAverage = ((Double) in.readValue((Double.class.getClassLoader())));
this.title = ((String) in.readValue((String.class.getClassLoader())));
this.popularity = ((Double) in.readValue((Double.class.getClassLoader())));
this.posterPath = ((String) in.readValue((String.class.getClassLoader())));
this.originalLanguage = ((String) in.readValue((String.class.getClassLoader())));
this.originalTitle = ((String) in.readValue((String.class.getClassLoader())));
in.readList(this.genreIds, (java.lang.Integer.class.getClassLoader()));
this.backdropPath = ((String) in.readValue((String.class.getClassLoader())));
this.adult = ((Boolean) in.readValue((Boolean.class.getClassLoader())));
this.overview = ((String) in.readValue((String.class.getClassLoader())));
this.releaseDate = ((String) in.readValue((String.class.getClassLoader())));
}
public Movie() {
}
@Bindable
public Integer getVoteCount() {
return voteCount;
}
public void setVoteCount(Integer voteCount) {
this.voteCount = voteCount;
notifyPropertyChanged(BR.voteCount);
}
@Bindable
public Integer getId() {
return id;
}
public void setId(Integer id)
{
this.id = id;
notifyPropertyChanged(com.example.tmdbclient.BR.id);
}
@Bindable
public Boolean getVideo() {
return video;
}
public void setVideo(Boolean video) {
this.video = video;
notifyPropertyChanged(BR.video);
}
@Bindable
public Double getVoteAverage() {
return voteAverage;
}
public void setVoteAverage(Double voteAverage) {
this.voteAverage = voteAverage;
notifyPropertyChanged(BR.voteAverage);
}
@Bindable
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
notifyPropertyChanged(BR.title);
}
@Bindable
public Double getPopularity() {
return popularity;
}
public void setPopularity(Double popularity) {
this.popularity = popularity;
notifyPropertyChanged(BR.popularity);
}
@Bindable
public String getPosterPath() {
return posterPath;
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
notifyPropertyChanged(BR.posterPath);
}
@Bindable
public String getOriginalLanguage() {
return originalLanguage;
}
public void setOriginalLanguage(String originalLanguage) {
this.originalLanguage = originalLanguage;
notifyPropertyChanged(BR.originalLanguage);
}
@Bindable
public String getOriginalTitle() {
return originalTitle;
}
public void setOriginalTitle(String originalTitle) {
this.originalTitle = originalTitle;
notifyPropertyChanged(BR.originalTitle);
}
@Bindable
public List<Integer> getGenreIds() {
return genreIds;
}
public void setGenreIds(List<Integer> genreIds) {
this.genreIds = genreIds;
notifyPropertyChanged(BR.genreIds);
}
@Bindable
public String getBackdropPath() {
return backdropPath;
}
public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath;
notifyPropertyChanged(BR.backdropPath);
}
@Bindable
public Boolean getAdult() {
return adult;
}
public void setAdult(Boolean adult) {
this.adult = adult;
notifyPropertyChanged(BR.adult);
}
@Bindable
public String getOverview() {
return overview;
}
public void setOverview(String overview) {
this.overview = overview;
notifyPropertyChanged(BR.overview);
}
@Bindable
public String getReleaseDate() {
return releaseDate;
}
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
notifyPropertyChanged(BR.releaseDate);
}
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(voteCount);
dest.writeValue(id);
dest.writeValue(video);
dest.writeValue(voteAverage);
dest.writeValue(title);
dest.writeValue(popularity);
dest.writeValue(posterPath);
dest.writeValue(originalLanguage);
dest.writeValue(originalTitle);
dest.writeList(genreIds);
dest.writeValue(backdropPath);
dest.writeValue(adult);
dest.writeValue(overview);
dest.writeValue(releaseDate);
}
public int describeContents() {
return 0;
}
}
<小时/>
Activity 主
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".view.MainActivity"
android:layout_marginTop="15dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvMovies"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:scrollbars="vertical"/>
</RelativeLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</layout>
<小时/>
Activity 电影
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="movie"
type="com.example.tmdbclient.model.Movie" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".view.MovieActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Widget.Design.AppBarLayout">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/ctMovie"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivMovieLarge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
bind:posterPath="@{movie.posterPath}" />
</RelativeLayout>
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<include
android:id="@+id/secondary_layout"
layout="@layout/content_movie"
bind:secondaryMovie="@{movie}" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
<小时/>
内容电影
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="secondaryMovie"
type="com.example.tmdbclient.model.Movie" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".view.MovieActivity"
tools:showIn="@layout/activity_movie">
<LinearLayout
android:id="@+id/add"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:showIn="@layout/activity_movie">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvMovieTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:padding="16dp"
android:text="@{secondaryMovie.title}"
android:textSize="20sp"
app:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_creator="1"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvRating"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:padding="16dp"
android:text="@{Double.toString(secondaryMovie.voteAverage)}"
android:textSize="16sp"
app:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_creator="1"
app:layout_constraintTop_toBottomOf="@id/tvMovieTitle"
/>
<TextView
android:id="@+id/tvSynopsis"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:padding="16dp"
android:text="@{secondaryMovie.overview}"
android:textSize="16sp"
app:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_creator="1"
app:layout_constraintTop_toBottomOf="@id/tvRating"
/>
<TextView
android:id="@+id/tvRelease"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:padding="16dp"
android:text="@{secondaryMovie.releaseDate}"
android:textSize="16sp"
app:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_creator="1"
app:layout_constraintTop_toBottomOf="@id/tvSynopsis"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
</layout>
<小时/>
电影列表项
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="movie"
type="com.example.tmdbclient.model.Movie" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:id="@+id/cvMovie"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:elevation="3dp"
app:cardCornerRadius="3dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/ivMovie"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="fitXY"
bind:posterPath="@{movie.posterPath}" />
<TextView
android:id="@+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ivMovie"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:text="@{movie.title}"
android:textColor="@color/colorPrimary"
android:textSize="15sp" />
<TextView
android:id="@+id/tvRating"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tvTitle"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:text="@{Double.toString(movie.voteAverage)}"
android:textColor="@color/colorPrimary"
android:textSize="15sp" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</layout>
最佳答案
你应该做的第一件事是
更改这些行
implementation 'com.android.support:cardview-v7:29.0.0'
implementation 'com.android.support:recyclerview-v7:29.0.0'
implementation 'com.android.support:design:29.0.0'
到
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.design:design:1.0.0'
问题出在 Movie
类的 loadImage
方法上。将其定义为静态并且它应该可以工作。
关于java - 使缓存失效并重新启动并不能修复 BR 导入错误...数据绑定(bind)问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56655642/
我搜索了重启我的 android 应用程序的替代方法,但我发现重启的唯一方法是使用 Flex 构建. 我可以用 as3 flash 重启我的 android adobe air 应用程序吗?我该怎么做
我有一个学校评估,是为了制作一个 child 的拼写游戏,当玩家单击"is"时,它必须循环/重新启动。到目前为止,当我测试游戏时,询问玩家是否想再次玩的选项/easygui.buttonbox 以
在.yml文件中,我定义了:restart: always。是否可以将此重启创建为--force-recreate标志的等效项? 我的XVFB有问题,标准重启无法解决问题,但通过--force-rec
我正在尝试重新启动 while 循环。我已经声明了 boolean 类型的变量 keepGoing 。如果 int 变量 x 超出窗口,则 keepGoing 更改为 false。然后reset()方
如何使用 Cast SDK 或其他方式让我的应用以官方 Chromecast 应用的方式触发 Chromecast 重启? 如果是“否则”,Google Play 可能会对这种做法不友善吗? 最佳答案
运行/etc/init.d/postgresql restart有没有危险?我们刚刚发生了一些关系“消失”的事件,我运行了上述命令。刚刚被系统管理员骂了一顿,但是他没有解释为什么这是一件坏事。我确实将
是否可以重新启动 while 循环?我目前在 foreach 循环中存在一个 while 循环,并且每次都需要 while 语句从头开始。 $sql = mysqli_query($link, "SE
我有如下倒计时器: - (void)updateCounterLabel:(NSTimer *)theTimer { if(secondsLeft > 0 ){ secondsLeft
就像我在 python 中一样。 choice1 = raw_input('John Blue Green') if choice1 == 'A': print('blah') elif cho
我的游戏在 True 循环中运行一段时间,我希望能够要求用户“再玩一次?”我已经有了用于弹出文本的矩形的代码,但我需要一种方法让用户单击矩形或按 y 表示是,然后代码再次自行运行。 最佳答案 在您的主
我是 nginx 的初学者。我正在使用 Ubuntu 16.04。我按照步骤操作, sudo apt-get 更新。 sudo apt-get install nginx sudo apt-get 升
我需要使用 javascript 重放一个 css 转换。当我重置我的 div 的 css 样式并应用新的过渡时,没有任何反应...... 我认为这两个代码是在同一个执行框架中执行的,并且通过优化,它
所以我有这几行代码: string[] newData = File.ReadAllLines(fileName) int length = newData.Length; for (int i =
所以我有一个计时器,每 5 秒旋转一组图像。因此,我在文档启动时运行它。 $(document).ready(function() { var intervalID=setInterval(funct
好吧,我在重新启动 Apache 服务器时遇到了一些问题。我修改了服务器上的 ulimit 但我无法重新启动 httpd; 我在 CentOS 5.8 x64 上运行服务器. httpd -V 的输出
我在使用 docker 时遇到问题 docker ps不会返回并被卡住。 我发现做 docker service restart 之类的sudo service docker restart (htt
从 .net 代码停止和重新启动 Storyboard的正确方法是什么? 我想 ... myStory.Stop(this); 期望随后调用 .Begin(this);将从零开始从时间线重新开始,但
我有一个带有一些缓存后端的应用程序,我想在重新启动网络服务器时清除缓存。 在网络服务器(重新)启动时是否有 apache 配置指令或任何其他方式来执行 shell 脚本? 谢谢, 菲尔 正如一些答案已
我愿意在我的应用程序中添加一个按钮,单击该按钮将重新启动应用程序。我搜索了谷歌,但发现除了 this one 没有任何帮助.但是这里遵循的程序违反了 Java 的 WORA 概念。 是否还有其他以 J
我们目前遇到间歇性邮件队列中断。我是 seeking diagnostic help in another area . 同时,有没有办法在不重启整个服务的情况下重启CF邮件队列? CF8标准 Win
我是一名优秀的程序员,十分优秀!