一旦我尝试从Realm数据库中获取对象,应用程序崩溃了,我收到此错误:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.repdev.realtimedelijn/com.repdev.realtimedelijn.activity.MainActivity}:
java.lang.IllegalArgumentException: Haltes is not part of the schema for this Realm
Run Code Online (Sandbox Code Playgroud)
这是我的活动它发生了
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_main);
Context context = this;
View view = this.getWindow().getDecorView();
realm = Realm.getInstance(getRealmConfiguration());
RealmResults<Haltes> haltes = realm
.where(Haltes.class)
.findAll();
HaltesRecyclerViewAdapter haltesRecyclerViewAdapter =
new HaltesRecyclerViewAdapter(this, haltes, true, true);
RealmRecyclerView realmRecyclerView =
(RealmRecyclerView) findViewById(R.id.realm_recycler_view);
realmRecyclerView.setAdapter(haltesRecyclerViewAdapter);
}
Run Code Online (Sandbox Code Playgroud)
这是模型
有人知道如何解决它?公共类Haltes实现RealmModel {
@PrimaryKey
private long id;
private String halteNaam;
private String halteNummer;
public long getId() {
return …Run Code Online (Sandbox Code Playgroud) 所以我在一个集合视图中有一个单元格,里面有3个按钮.为了使用这些按钮触发代码,我实现了一个自定义委托.现在代码被触发,但我不知道代码触发了哪个单元格.我怎样才能最好地实现这一点?这是我的一些代码.协议:
protocol OverViewDelegate {
func registerButtonClicked()
func evaluateButtonClicked()
func overviewButtonClicked()
}
Run Code Online (Sandbox Code Playgroud)
cellForItemAt:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "sessionCell", for: indexPath) as? SessionCollectionViewCell
let session: SessionModel
session = DebugData.shared.sessionArray[indexPath.row]
cell?.sessionImage.image = #imageLiteral(resourceName: "carControl")
cell?.sessionNameLabel.text = session.name
cell?.sessionLocationLabel.text = session.location
cell?.overViewDelegate = self
return cell!
}
Run Code Online (Sandbox Code Playgroud)
细胞:
import UIKit
Run Code Online (Sandbox Code Playgroud)
导入IBAnimatable
@IBOutlet weak var sessionImage: UIImageView!
@IBOutlet weak var sessionNameLabel: UILabel!
@IBOutlet weak var sessionLocationLabel: UILabel!
@IBOutlet weak var sessionRegisterButton: AnimatableButton!
@IBOutlet weak var …Run Code Online (Sandbox Code Playgroud)