Nusret Özateş
Nusret Özateş

Reputation: 94

How to use ObservableList in Android Studio?

I must use this code on my android Project but I can't find it in Android.

I google it and find there is "android.databind.ObservableArrayList" but in Android Studio I can't find it.

 private ObservableList<Urunler> data = FXCollections.observableArrayList();

Upvotes: 1

Views: 5446

Answers (2)

hvar90
hvar90

Reputation: 215

To use ObservableArrayList you need to download the library from the Support repository in the Android SDK manager.

To configure your app to use data binding, add the dataBinding element to your build.gradle file in the app module.

Use the following code snippet to configure data binding:

dataBinding {
    enabled = true
}

after that you will be able to use ObservableArrayList in Android Studio

(read the docs)

Upvotes: 3

vikas kumar
vikas kumar

Reputation: 11018

The code mentioned uses JavaFx 8 API's. Make sure your IDE is using java 8 JavaFX API if not include them or update your JDK. Get a copy of JDK from the official website.

Read FxCollections docs here

Read ObservableList docs here

Upvotes: 0

Related Questions