Android Firebase List Adapters Constructor Error












0















I'm trying to create a list view with the data from the Firebase real time database.For some reason I am keep getting a red line under this code.Hope you can let me know what is my mistake here. Thank you :). I have attached my layout file and also my app gradle codes.



(this,String.class,android.R.layout.simple_list_item_1,databaseReference)

Below here is the complete code

DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReferenceFromUrl("https://vsem-inventory.firebaseio.com/");
FirebaseListAdapter<String> firebaseListAdapter = new FirebaseListAdapter<String>(this,String.class,android.R.layout.simple_list_item_1,databaseReference) {
@Override
protected void populateView(@NonNull View v, @NonNull String model, int position) {
TextView textView = v.findViewById(android.R.id.text1);
}
};

mListView.setAdapter(firebaseListAdapter);


content_main_menu.xml



  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainMenu">

<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp" />
</RelativeLayout>


App gradle



 apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.user.vseminventory"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.android.support:design:28.0.0'
implementation 'com.firebase:firebase-client-android:2.3.1'
implementation 'com.firebaseui:firebase-ui-database:4.3.0'
}

apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true









share|improve this question

























  • Can you please state the error which is encountered

    – Nero
    Jan 2 at 9:07











  • It just states compilation error

    – Blacky_99
    Jan 2 at 9:19











  • Please share the entire code of the activity including your gradle

    – Nero
    Jan 2 at 9:27
















0















I'm trying to create a list view with the data from the Firebase real time database.For some reason I am keep getting a red line under this code.Hope you can let me know what is my mistake here. Thank you :). I have attached my layout file and also my app gradle codes.



(this,String.class,android.R.layout.simple_list_item_1,databaseReference)

Below here is the complete code

DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReferenceFromUrl("https://vsem-inventory.firebaseio.com/");
FirebaseListAdapter<String> firebaseListAdapter = new FirebaseListAdapter<String>(this,String.class,android.R.layout.simple_list_item_1,databaseReference) {
@Override
protected void populateView(@NonNull View v, @NonNull String model, int position) {
TextView textView = v.findViewById(android.R.id.text1);
}
};

mListView.setAdapter(firebaseListAdapter);


content_main_menu.xml



  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainMenu">

<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp" />
</RelativeLayout>


App gradle



 apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.user.vseminventory"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.android.support:design:28.0.0'
implementation 'com.firebase:firebase-client-android:2.3.1'
implementation 'com.firebaseui:firebase-ui-database:4.3.0'
}

apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true









share|improve this question

























  • Can you please state the error which is encountered

    – Nero
    Jan 2 at 9:07











  • It just states compilation error

    – Blacky_99
    Jan 2 at 9:19











  • Please share the entire code of the activity including your gradle

    – Nero
    Jan 2 at 9:27














0












0








0








I'm trying to create a list view with the data from the Firebase real time database.For some reason I am keep getting a red line under this code.Hope you can let me know what is my mistake here. Thank you :). I have attached my layout file and also my app gradle codes.



(this,String.class,android.R.layout.simple_list_item_1,databaseReference)

Below here is the complete code

DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReferenceFromUrl("https://vsem-inventory.firebaseio.com/");
FirebaseListAdapter<String> firebaseListAdapter = new FirebaseListAdapter<String>(this,String.class,android.R.layout.simple_list_item_1,databaseReference) {
@Override
protected void populateView(@NonNull View v, @NonNull String model, int position) {
TextView textView = v.findViewById(android.R.id.text1);
}
};

mListView.setAdapter(firebaseListAdapter);


content_main_menu.xml



  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainMenu">

<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp" />
</RelativeLayout>


App gradle



 apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.user.vseminventory"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.android.support:design:28.0.0'
implementation 'com.firebase:firebase-client-android:2.3.1'
implementation 'com.firebaseui:firebase-ui-database:4.3.0'
}

apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true









share|improve this question
















I'm trying to create a list view with the data from the Firebase real time database.For some reason I am keep getting a red line under this code.Hope you can let me know what is my mistake here. Thank you :). I have attached my layout file and also my app gradle codes.



(this,String.class,android.R.layout.simple_list_item_1,databaseReference)

Below here is the complete code

DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReferenceFromUrl("https://vsem-inventory.firebaseio.com/");
FirebaseListAdapter<String> firebaseListAdapter = new FirebaseListAdapter<String>(this,String.class,android.R.layout.simple_list_item_1,databaseReference) {
@Override
protected void populateView(@NonNull View v, @NonNull String model, int position) {
TextView textView = v.findViewById(android.R.id.text1);
}
};

mListView.setAdapter(firebaseListAdapter);


content_main_menu.xml



  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainMenu">

<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp" />
</RelativeLayout>


App gradle



 apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.user.vseminventory"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.android.support:design:28.0.0'
implementation 'com.firebase:firebase-client-android:2.3.1'
implementation 'com.firebaseui:firebase-ui-database:4.3.0'
}

apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true






android firebase android-studio firebase-realtime-database android-listview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 9:34







Blacky_99

















asked Jan 2 at 9:02









Blacky_99Blacky_99

2018




2018













  • Can you please state the error which is encountered

    – Nero
    Jan 2 at 9:07











  • It just states compilation error

    – Blacky_99
    Jan 2 at 9:19











  • Please share the entire code of the activity including your gradle

    – Nero
    Jan 2 at 9:27



















  • Can you please state the error which is encountered

    – Nero
    Jan 2 at 9:07











  • It just states compilation error

    – Blacky_99
    Jan 2 at 9:19











  • Please share the entire code of the activity including your gradle

    – Nero
    Jan 2 at 9:27

















Can you please state the error which is encountered

– Nero
Jan 2 at 9:07





Can you please state the error which is encountered

– Nero
Jan 2 at 9:07













It just states compilation error

– Blacky_99
Jan 2 at 9:19





It just states compilation error

– Blacky_99
Jan 2 at 9:19













Please share the entire code of the activity including your gradle

– Nero
Jan 2 at 9:27





Please share the entire code of the activity including your gradle

– Nero
Jan 2 at 9:27












1 Answer
1






active

oldest

votes


















0














It seems you are using the new Firebaseui (version 3.0+), the constructor of the FirebaseListAdapter was changed.



First, you need to configure the adapter by using the class FirebaseListOptions, then you can create an instance of FirebaseListAdapter.



Check this code from the docs:



 FirebaseListOptions<Chat> options = new FirebaseListOptions.Builder<Chat>()
.setQuery(query, Chat.class)
.build();

FirebaseListAdapter<Chat> adapter = new FirebaseListAdapter<Chat>(options) {
@Override
protected void populateView(View v, Chat model, int position) {
// Bind the Chat to the view
// ...
}
};


As you can see the FirebaseListAdapter takes a parameter of type FirebaseListOptions



More info here:



https://github.com/firebase/FirebaseUI-Android/blob/master/database/README.md#using-firebaseui-to-populate-a-listview





You can see the source code here:



https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java






share|improve this answer
























  • What do i change the query in .setQuery (query,...) with?

    – Blacky_99
    Jan 2 at 9:45











  • SetQuery(databaseReference, String.class)

    – Peter Haddad
    Jan 2 at 9:46













  • Don't forget to read the docs linked in the answer and add startListening() and stopListening()

    – Peter Haddad
    Jan 2 at 9:47













  • @Blacky_99 did the answer help you?

    – Peter Haddad
    Jan 2 at 11:40











  • sorry for the late reply, my app compiles but it crashes. :(

    – Blacky_99
    Jan 3 at 1:18











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54003607%2fandroid-firebase-list-adapters-constructor-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














It seems you are using the new Firebaseui (version 3.0+), the constructor of the FirebaseListAdapter was changed.



First, you need to configure the adapter by using the class FirebaseListOptions, then you can create an instance of FirebaseListAdapter.



Check this code from the docs:



 FirebaseListOptions<Chat> options = new FirebaseListOptions.Builder<Chat>()
.setQuery(query, Chat.class)
.build();

FirebaseListAdapter<Chat> adapter = new FirebaseListAdapter<Chat>(options) {
@Override
protected void populateView(View v, Chat model, int position) {
// Bind the Chat to the view
// ...
}
};


As you can see the FirebaseListAdapter takes a parameter of type FirebaseListOptions



More info here:



https://github.com/firebase/FirebaseUI-Android/blob/master/database/README.md#using-firebaseui-to-populate-a-listview





You can see the source code here:



https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java






share|improve this answer
























  • What do i change the query in .setQuery (query,...) with?

    – Blacky_99
    Jan 2 at 9:45











  • SetQuery(databaseReference, String.class)

    – Peter Haddad
    Jan 2 at 9:46













  • Don't forget to read the docs linked in the answer and add startListening() and stopListening()

    – Peter Haddad
    Jan 2 at 9:47













  • @Blacky_99 did the answer help you?

    – Peter Haddad
    Jan 2 at 11:40











  • sorry for the late reply, my app compiles but it crashes. :(

    – Blacky_99
    Jan 3 at 1:18
















0














It seems you are using the new Firebaseui (version 3.0+), the constructor of the FirebaseListAdapter was changed.



First, you need to configure the adapter by using the class FirebaseListOptions, then you can create an instance of FirebaseListAdapter.



Check this code from the docs:



 FirebaseListOptions<Chat> options = new FirebaseListOptions.Builder<Chat>()
.setQuery(query, Chat.class)
.build();

FirebaseListAdapter<Chat> adapter = new FirebaseListAdapter<Chat>(options) {
@Override
protected void populateView(View v, Chat model, int position) {
// Bind the Chat to the view
// ...
}
};


As you can see the FirebaseListAdapter takes a parameter of type FirebaseListOptions



More info here:



https://github.com/firebase/FirebaseUI-Android/blob/master/database/README.md#using-firebaseui-to-populate-a-listview





You can see the source code here:



https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java






share|improve this answer
























  • What do i change the query in .setQuery (query,...) with?

    – Blacky_99
    Jan 2 at 9:45











  • SetQuery(databaseReference, String.class)

    – Peter Haddad
    Jan 2 at 9:46













  • Don't forget to read the docs linked in the answer and add startListening() and stopListening()

    – Peter Haddad
    Jan 2 at 9:47













  • @Blacky_99 did the answer help you?

    – Peter Haddad
    Jan 2 at 11:40











  • sorry for the late reply, my app compiles but it crashes. :(

    – Blacky_99
    Jan 3 at 1:18














0












0








0







It seems you are using the new Firebaseui (version 3.0+), the constructor of the FirebaseListAdapter was changed.



First, you need to configure the adapter by using the class FirebaseListOptions, then you can create an instance of FirebaseListAdapter.



Check this code from the docs:



 FirebaseListOptions<Chat> options = new FirebaseListOptions.Builder<Chat>()
.setQuery(query, Chat.class)
.build();

FirebaseListAdapter<Chat> adapter = new FirebaseListAdapter<Chat>(options) {
@Override
protected void populateView(View v, Chat model, int position) {
// Bind the Chat to the view
// ...
}
};


As you can see the FirebaseListAdapter takes a parameter of type FirebaseListOptions



More info here:



https://github.com/firebase/FirebaseUI-Android/blob/master/database/README.md#using-firebaseui-to-populate-a-listview





You can see the source code here:



https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java






share|improve this answer













It seems you are using the new Firebaseui (version 3.0+), the constructor of the FirebaseListAdapter was changed.



First, you need to configure the adapter by using the class FirebaseListOptions, then you can create an instance of FirebaseListAdapter.



Check this code from the docs:



 FirebaseListOptions<Chat> options = new FirebaseListOptions.Builder<Chat>()
.setQuery(query, Chat.class)
.build();

FirebaseListAdapter<Chat> adapter = new FirebaseListAdapter<Chat>(options) {
@Override
protected void populateView(View v, Chat model, int position) {
// Bind the Chat to the view
// ...
}
};


As you can see the FirebaseListAdapter takes a parameter of type FirebaseListOptions



More info here:



https://github.com/firebase/FirebaseUI-Android/blob/master/database/README.md#using-firebaseui-to-populate-a-listview





You can see the source code here:



https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 2 at 9:32









Peter HaddadPeter Haddad

21.7k94459




21.7k94459













  • What do i change the query in .setQuery (query,...) with?

    – Blacky_99
    Jan 2 at 9:45











  • SetQuery(databaseReference, String.class)

    – Peter Haddad
    Jan 2 at 9:46













  • Don't forget to read the docs linked in the answer and add startListening() and stopListening()

    – Peter Haddad
    Jan 2 at 9:47













  • @Blacky_99 did the answer help you?

    – Peter Haddad
    Jan 2 at 11:40











  • sorry for the late reply, my app compiles but it crashes. :(

    – Blacky_99
    Jan 3 at 1:18



















  • What do i change the query in .setQuery (query,...) with?

    – Blacky_99
    Jan 2 at 9:45











  • SetQuery(databaseReference, String.class)

    – Peter Haddad
    Jan 2 at 9:46













  • Don't forget to read the docs linked in the answer and add startListening() and stopListening()

    – Peter Haddad
    Jan 2 at 9:47













  • @Blacky_99 did the answer help you?

    – Peter Haddad
    Jan 2 at 11:40











  • sorry for the late reply, my app compiles but it crashes. :(

    – Blacky_99
    Jan 3 at 1:18

















What do i change the query in .setQuery (query,...) with?

– Blacky_99
Jan 2 at 9:45





What do i change the query in .setQuery (query,...) with?

– Blacky_99
Jan 2 at 9:45













SetQuery(databaseReference, String.class)

– Peter Haddad
Jan 2 at 9:46







SetQuery(databaseReference, String.class)

– Peter Haddad
Jan 2 at 9:46















Don't forget to read the docs linked in the answer and add startListening() and stopListening()

– Peter Haddad
Jan 2 at 9:47







Don't forget to read the docs linked in the answer and add startListening() and stopListening()

– Peter Haddad
Jan 2 at 9:47















@Blacky_99 did the answer help you?

– Peter Haddad
Jan 2 at 11:40





@Blacky_99 did the answer help you?

– Peter Haddad
Jan 2 at 11:40













sorry for the late reply, my app compiles but it crashes. :(

– Blacky_99
Jan 3 at 1:18





sorry for the late reply, my app compiles but it crashes. :(

– Blacky_99
Jan 3 at 1:18




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54003607%2fandroid-firebase-list-adapters-constructor-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$