Retrieve data from Android Firebase , display it to a listview and apply onItemClickListener to the ListView
I am new to Android Development.
I want to retrieve all the titles(Title 1, Title 2, Title 3, Title 4
) from Firebase and display in a listview
which I am able to do. But I want to apply onItemClickListener
to the listview
and I want that when I click a particular item in listview
the next activity should show me the particular content.
eg if I click Title 1
then the next activity should display Content 1
. If Title 2
then Content 2
.
Please show how can I do this.`
advaitavedanta-f1443
Chapter 1
description: "Content 1"
title: "Title 1"
Chapter 2
description: "Content 2"
title: "Title 2"
Chapter 3
description: "Content 3"
title: "Title 3"
Chapter 4
description: "Content 4"
title: "Title 4"
//this is my data from firebase//
private static final String TAG = "MainActivity";
private FirebaseDatabase mDatabase;
private DatabaseReference mDbRef;
String Title;
String Description;
ListView listView;
ArrayList<String> mybook = new ArrayList<>();
ArrayAdapter<String> arrayAdapter;
Firebase url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDatabase = FirebaseDatabase.getInstance();
mDbRef = mDatabase.getReference("Chapter 1");
User user = new User("Title 1", "Content 1");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 2");
user = new User("Title 2", "Content 2");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 3");
user = new User("Title 3", "Content 3");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 4");
user = new User("Title 4", "Content 4");
mDbRef.setValue(user);
Firebase.setAndroidContext(this);
listView = findViewById(R.id.listView);
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, notes);
listView.setAdapter(arrayAdapter);
url = new Firebase("https://advaitavedanta-f1443.firebaseio.com/");
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("noteId", Description);
}
});
url.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Title = dataSnapshot.child("title").getValue(String.class);
mybook.add(Title);
Description = dataSnapshot.child("description").getValue(String.class);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
}`
firebase

add a comment |
I am new to Android Development.
I want to retrieve all the titles(Title 1, Title 2, Title 3, Title 4
) from Firebase and display in a listview
which I am able to do. But I want to apply onItemClickListener
to the listview
and I want that when I click a particular item in listview
the next activity should show me the particular content.
eg if I click Title 1
then the next activity should display Content 1
. If Title 2
then Content 2
.
Please show how can I do this.`
advaitavedanta-f1443
Chapter 1
description: "Content 1"
title: "Title 1"
Chapter 2
description: "Content 2"
title: "Title 2"
Chapter 3
description: "Content 3"
title: "Title 3"
Chapter 4
description: "Content 4"
title: "Title 4"
//this is my data from firebase//
private static final String TAG = "MainActivity";
private FirebaseDatabase mDatabase;
private DatabaseReference mDbRef;
String Title;
String Description;
ListView listView;
ArrayList<String> mybook = new ArrayList<>();
ArrayAdapter<String> arrayAdapter;
Firebase url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDatabase = FirebaseDatabase.getInstance();
mDbRef = mDatabase.getReference("Chapter 1");
User user = new User("Title 1", "Content 1");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 2");
user = new User("Title 2", "Content 2");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 3");
user = new User("Title 3", "Content 3");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 4");
user = new User("Title 4", "Content 4");
mDbRef.setValue(user);
Firebase.setAndroidContext(this);
listView = findViewById(R.id.listView);
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, notes);
listView.setAdapter(arrayAdapter);
url = new Firebase("https://advaitavedanta-f1443.firebaseio.com/");
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("noteId", Description);
}
});
url.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Title = dataSnapshot.child("title").getValue(String.class);
mybook.add(Title);
Description = dataSnapshot.child("description").getValue(String.class);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
}`
firebase

1
You have posted the code that you have, but what exactly is the problem that you are receiving? Is the code not working? What's the problem?
– Ishaan Javali
Nov 21 '18 at 22:55
I am getting the data in listview but I am not getting the data when I click on any item. The next activity is blank. I want to know that when I click on any item in listview it should display corresponding content in next activity( suppose I click ' title 1' next activity should show 'content 1' . Please see the firebase data at top.
– sam
Nov 21 '18 at 23:58
Ok. I know how to get this working. Create your own Adapter class and inside thegetView
method of your Adapter class, set the stuff in theonClickListener
. You will also need to require the application context as one of the constructor's parameters.
– Ishaan Javali
Nov 22 '18 at 0:01
This article explains very well how to make a custom adapter class.
– Ishaan Javali
Nov 22 '18 at 0:02
add a comment |
I am new to Android Development.
I want to retrieve all the titles(Title 1, Title 2, Title 3, Title 4
) from Firebase and display in a listview
which I am able to do. But I want to apply onItemClickListener
to the listview
and I want that when I click a particular item in listview
the next activity should show me the particular content.
eg if I click Title 1
then the next activity should display Content 1
. If Title 2
then Content 2
.
Please show how can I do this.`
advaitavedanta-f1443
Chapter 1
description: "Content 1"
title: "Title 1"
Chapter 2
description: "Content 2"
title: "Title 2"
Chapter 3
description: "Content 3"
title: "Title 3"
Chapter 4
description: "Content 4"
title: "Title 4"
//this is my data from firebase//
private static final String TAG = "MainActivity";
private FirebaseDatabase mDatabase;
private DatabaseReference mDbRef;
String Title;
String Description;
ListView listView;
ArrayList<String> mybook = new ArrayList<>();
ArrayAdapter<String> arrayAdapter;
Firebase url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDatabase = FirebaseDatabase.getInstance();
mDbRef = mDatabase.getReference("Chapter 1");
User user = new User("Title 1", "Content 1");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 2");
user = new User("Title 2", "Content 2");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 3");
user = new User("Title 3", "Content 3");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 4");
user = new User("Title 4", "Content 4");
mDbRef.setValue(user);
Firebase.setAndroidContext(this);
listView = findViewById(R.id.listView);
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, notes);
listView.setAdapter(arrayAdapter);
url = new Firebase("https://advaitavedanta-f1443.firebaseio.com/");
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("noteId", Description);
}
});
url.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Title = dataSnapshot.child("title").getValue(String.class);
mybook.add(Title);
Description = dataSnapshot.child("description").getValue(String.class);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
}`
firebase

I am new to Android Development.
I want to retrieve all the titles(Title 1, Title 2, Title 3, Title 4
) from Firebase and display in a listview
which I am able to do. But I want to apply onItemClickListener
to the listview
and I want that when I click a particular item in listview
the next activity should show me the particular content.
eg if I click Title 1
then the next activity should display Content 1
. If Title 2
then Content 2
.
Please show how can I do this.`
advaitavedanta-f1443
Chapter 1
description: "Content 1"
title: "Title 1"
Chapter 2
description: "Content 2"
title: "Title 2"
Chapter 3
description: "Content 3"
title: "Title 3"
Chapter 4
description: "Content 4"
title: "Title 4"
//this is my data from firebase//
private static final String TAG = "MainActivity";
private FirebaseDatabase mDatabase;
private DatabaseReference mDbRef;
String Title;
String Description;
ListView listView;
ArrayList<String> mybook = new ArrayList<>();
ArrayAdapter<String> arrayAdapter;
Firebase url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDatabase = FirebaseDatabase.getInstance();
mDbRef = mDatabase.getReference("Chapter 1");
User user = new User("Title 1", "Content 1");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 2");
user = new User("Title 2", "Content 2");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 3");
user = new User("Title 3", "Content 3");
mDbRef.setValue(user);
mDbRef = mDatabase.getReference("Chapter 4");
user = new User("Title 4", "Content 4");
mDbRef.setValue(user);
Firebase.setAndroidContext(this);
listView = findViewById(R.id.listView);
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, notes);
listView.setAdapter(arrayAdapter);
url = new Firebase("https://advaitavedanta-f1443.firebaseio.com/");
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("noteId", Description);
}
});
url.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Title = dataSnapshot.child("title").getValue(String.class);
mybook.add(Title);
Description = dataSnapshot.child("description").getValue(String.class);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
}`
firebase

firebase

edited Nov 22 '18 at 2:20


bcperth
2,0251614
2,0251614
asked Nov 21 '18 at 22:43
samsam
153
153
1
You have posted the code that you have, but what exactly is the problem that you are receiving? Is the code not working? What's the problem?
– Ishaan Javali
Nov 21 '18 at 22:55
I am getting the data in listview but I am not getting the data when I click on any item. The next activity is blank. I want to know that when I click on any item in listview it should display corresponding content in next activity( suppose I click ' title 1' next activity should show 'content 1' . Please see the firebase data at top.
– sam
Nov 21 '18 at 23:58
Ok. I know how to get this working. Create your own Adapter class and inside thegetView
method of your Adapter class, set the stuff in theonClickListener
. You will also need to require the application context as one of the constructor's parameters.
– Ishaan Javali
Nov 22 '18 at 0:01
This article explains very well how to make a custom adapter class.
– Ishaan Javali
Nov 22 '18 at 0:02
add a comment |
1
You have posted the code that you have, but what exactly is the problem that you are receiving? Is the code not working? What's the problem?
– Ishaan Javali
Nov 21 '18 at 22:55
I am getting the data in listview but I am not getting the data when I click on any item. The next activity is blank. I want to know that when I click on any item in listview it should display corresponding content in next activity( suppose I click ' title 1' next activity should show 'content 1' . Please see the firebase data at top.
– sam
Nov 21 '18 at 23:58
Ok. I know how to get this working. Create your own Adapter class and inside thegetView
method of your Adapter class, set the stuff in theonClickListener
. You will also need to require the application context as one of the constructor's parameters.
– Ishaan Javali
Nov 22 '18 at 0:01
This article explains very well how to make a custom adapter class.
– Ishaan Javali
Nov 22 '18 at 0:02
1
1
You have posted the code that you have, but what exactly is the problem that you are receiving? Is the code not working? What's the problem?
– Ishaan Javali
Nov 21 '18 at 22:55
You have posted the code that you have, but what exactly is the problem that you are receiving? Is the code not working? What's the problem?
– Ishaan Javali
Nov 21 '18 at 22:55
I am getting the data in listview but I am not getting the data when I click on any item. The next activity is blank. I want to know that when I click on any item in listview it should display corresponding content in next activity( suppose I click ' title 1' next activity should show 'content 1' . Please see the firebase data at top.
– sam
Nov 21 '18 at 23:58
I am getting the data in listview but I am not getting the data when I click on any item. The next activity is blank. I want to know that when I click on any item in listview it should display corresponding content in next activity( suppose I click ' title 1' next activity should show 'content 1' . Please see the firebase data at top.
– sam
Nov 21 '18 at 23:58
Ok. I know how to get this working. Create your own Adapter class and inside the
getView
method of your Adapter class, set the stuff in the onClickListener
. You will also need to require the application context as one of the constructor's parameters.– Ishaan Javali
Nov 22 '18 at 0:01
Ok. I know how to get this working. Create your own Adapter class and inside the
getView
method of your Adapter class, set the stuff in the onClickListener
. You will also need to require the application context as one of the constructor's parameters.– Ishaan Javali
Nov 22 '18 at 0:01
This article explains very well how to make a custom adapter class.
– Ishaan Javali
Nov 22 '18 at 0:02
This article explains very well how to make a custom adapter class.
– Ishaan Javali
Nov 22 '18 at 0:02
add a comment |
2 Answers
2
active
oldest
votes
Since you are using User
object in adding firebase data, use list of user object in retrieving it on your child added.
Make a list of users
ArrayList<User> users = new ArrayList<>();
Then on your child added do this
String title = dataSnapshot.child("title").getValue(String.class);
String description= dataSnapshot.child("description").getValue(String.class);
users.add(new User(title, description));
Then finally, on your list click modify the extra
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("content_description", users.get(position).getDescription());
startActivity(intent);
Note: You could also put the whole object in the intent but you need to makeUser
object implement parcelable.
Suggestion: Use appropriate variable names and proper class names. Trust me this is important. For example, Title and Content shouldnt be in User
class, it more like to be in Book
class.
Hope this enlightens you mate, cheers
its not working bro.
– sam
Nov 22 '18 at 19:05
thanks bro. got my mistake.
– sam
Nov 23 '18 at 22:15
add a comment |
I see a potential problem with your code.
In your,
listView.setOnItemClickListener(...) , onItemClick()
there is no code to actually launch the new activity.
You are only forming the Intent
.
After,
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("noteId", Description);
You should add,
startActivity(intent);
Hope that gets you sorted.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421460%2fretrieve-data-from-android-firebase-display-it-to-a-listview-and-apply-onitemc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since you are using User
object in adding firebase data, use list of user object in retrieving it on your child added.
Make a list of users
ArrayList<User> users = new ArrayList<>();
Then on your child added do this
String title = dataSnapshot.child("title").getValue(String.class);
String description= dataSnapshot.child("description").getValue(String.class);
users.add(new User(title, description));
Then finally, on your list click modify the extra
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("content_description", users.get(position).getDescription());
startActivity(intent);
Note: You could also put the whole object in the intent but you need to makeUser
object implement parcelable.
Suggestion: Use appropriate variable names and proper class names. Trust me this is important. For example, Title and Content shouldnt be in User
class, it more like to be in Book
class.
Hope this enlightens you mate, cheers
its not working bro.
– sam
Nov 22 '18 at 19:05
thanks bro. got my mistake.
– sam
Nov 23 '18 at 22:15
add a comment |
Since you are using User
object in adding firebase data, use list of user object in retrieving it on your child added.
Make a list of users
ArrayList<User> users = new ArrayList<>();
Then on your child added do this
String title = dataSnapshot.child("title").getValue(String.class);
String description= dataSnapshot.child("description").getValue(String.class);
users.add(new User(title, description));
Then finally, on your list click modify the extra
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("content_description", users.get(position).getDescription());
startActivity(intent);
Note: You could also put the whole object in the intent but you need to makeUser
object implement parcelable.
Suggestion: Use appropriate variable names and proper class names. Trust me this is important. For example, Title and Content shouldnt be in User
class, it more like to be in Book
class.
Hope this enlightens you mate, cheers
its not working bro.
– sam
Nov 22 '18 at 19:05
thanks bro. got my mistake.
– sam
Nov 23 '18 at 22:15
add a comment |
Since you are using User
object in adding firebase data, use list of user object in retrieving it on your child added.
Make a list of users
ArrayList<User> users = new ArrayList<>();
Then on your child added do this
String title = dataSnapshot.child("title").getValue(String.class);
String description= dataSnapshot.child("description").getValue(String.class);
users.add(new User(title, description));
Then finally, on your list click modify the extra
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("content_description", users.get(position).getDescription());
startActivity(intent);
Note: You could also put the whole object in the intent but you need to makeUser
object implement parcelable.
Suggestion: Use appropriate variable names and proper class names. Trust me this is important. For example, Title and Content shouldnt be in User
class, it more like to be in Book
class.
Hope this enlightens you mate, cheers
Since you are using User
object in adding firebase data, use list of user object in retrieving it on your child added.
Make a list of users
ArrayList<User> users = new ArrayList<>();
Then on your child added do this
String title = dataSnapshot.child("title").getValue(String.class);
String description= dataSnapshot.child("description").getValue(String.class);
users.add(new User(title, description));
Then finally, on your list click modify the extra
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("content_description", users.get(position).getDescription());
startActivity(intent);
Note: You could also put the whole object in the intent but you need to makeUser
object implement parcelable.
Suggestion: Use appropriate variable names and proper class names. Trust me this is important. For example, Title and Content shouldnt be in User
class, it more like to be in Book
class.
Hope this enlightens you mate, cheers
answered Nov 22 '18 at 1:25


Android_K.DoeAndroid_K.Doe
655119
655119
its not working bro.
– sam
Nov 22 '18 at 19:05
thanks bro. got my mistake.
– sam
Nov 23 '18 at 22:15
add a comment |
its not working bro.
– sam
Nov 22 '18 at 19:05
thanks bro. got my mistake.
– sam
Nov 23 '18 at 22:15
its not working bro.
– sam
Nov 22 '18 at 19:05
its not working bro.
– sam
Nov 22 '18 at 19:05
thanks bro. got my mistake.
– sam
Nov 23 '18 at 22:15
thanks bro. got my mistake.
– sam
Nov 23 '18 at 22:15
add a comment |
I see a potential problem with your code.
In your,
listView.setOnItemClickListener(...) , onItemClick()
there is no code to actually launch the new activity.
You are only forming the Intent
.
After,
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("noteId", Description);
You should add,
startActivity(intent);
Hope that gets you sorted.
add a comment |
I see a potential problem with your code.
In your,
listView.setOnItemClickListener(...) , onItemClick()
there is no code to actually launch the new activity.
You are only forming the Intent
.
After,
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("noteId", Description);
You should add,
startActivity(intent);
Hope that gets you sorted.
add a comment |
I see a potential problem with your code.
In your,
listView.setOnItemClickListener(...) , onItemClick()
there is no code to actually launch the new activity.
You are only forming the Intent
.
After,
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("noteId", Description);
You should add,
startActivity(intent);
Hope that gets you sorted.
I see a potential problem with your code.
In your,
listView.setOnItemClickListener(...) , onItemClick()
there is no code to actually launch the new activity.
You are only forming the Intent
.
After,
Intent intent = new Intent(getApplicationContext(),MainContent.class);
intent.putExtra("noteId", Description);
You should add,
startActivity(intent);
Hope that gets you sorted.
answered Nov 22 '18 at 1:02


codeFoodcodeFood
8761111
8761111
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421460%2fretrieve-data-from-android-firebase-display-it-to-a-listview-and-apply-onitemc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
You have posted the code that you have, but what exactly is the problem that you are receiving? Is the code not working? What's the problem?
– Ishaan Javali
Nov 21 '18 at 22:55
I am getting the data in listview but I am not getting the data when I click on any item. The next activity is blank. I want to know that when I click on any item in listview it should display corresponding content in next activity( suppose I click ' title 1' next activity should show 'content 1' . Please see the firebase data at top.
– sam
Nov 21 '18 at 23:58
Ok. I know how to get this working. Create your own Adapter class and inside the
getView
method of your Adapter class, set the stuff in theonClickListener
. You will also need to require the application context as one of the constructor's parameters.– Ishaan Javali
Nov 22 '18 at 0:01
This article explains very well how to make a custom adapter class.
– Ishaan Javali
Nov 22 '18 at 0:02