How to update icon dynamically in contacts for my android app? - java

I am working on a app which add its icon in android default contacts app just like whatsApp icon appears in contact info. I want to update my apps icon dynamically on receiving some events, say a user comes online, then icon in contact list should be different then the icon shown when user is offline.
Can anyone suggest any way to do this?
Thanks

I assume your contact list is a ListView, and that you have an adapter that inflates each cells layout (that is, displays the icon and name of the contact).
Whenever you detect a change has occurred (an event was received) (maybe consider using a Loader if you aren't already), you should be able to call Adapter.notifyDataSetChanged() to update the cells.

Related

How to choose a category in food ordering app which opens that particular section?

I'm making a food ordering application on java using Android Studio IDE. I have designed my application in a way that it has a section called categories in which I have implemented a recyclerView to show the different categories.
I have also figured out to open a fragment with the specific item image and name on which the user has clicked. Now comes the main problem.
I want to display a recyclerView whenever any of the category is opened and that recyclerView should show the data of that specific category. Means, if user is entering into Pizza category so that recyclerView should show him all the pizzas that I have listed on my firebase database. And when the user click on Burger category, that recyclerView should show all the burgers there.
Please help me in this, as I have taken this project and now I'm stucked with this situation.
I'm attaching some images below to help understanding easily.
The image showing the categories.
The image showing the fragment opening after clicked on Pizza category.
The image showing the code of RecyclerView.
If anything else is required related to the code, I will be happy to share it.
I have tried using switch case but then I figured out that I can not update the code each time a new category is added to add a new case for each category. Also, I got failed while implementing that too!

Android studio: How to dynamically display and refresh a custom list which is horizontally and vertically oriented at the same time?

So I've been developping an app on Android Studio and at some point I need to display couples of values composed of texts and images but I have some issues with the display.
Let's say here that I want a list of fruit names associated with a picture, I'd like to display it that way :
Example
Each image and its related text is in linearlayout, so it's a list of linearlayouts.
The "add fruit" button open an alerdialog where the text and the image can be chosen, by clicking the 'ok' button in the alertdialog the name and the image are saved in a sqlLite database (which I already have programmed), and the linearlayout has to be added in the current list as the dialog is dismissed.
So the issue here is that:
I don't really know how to dynamically display each one of these linearlayouts in this specific order.
I don't know how to make it so that when a new fruit is added and the dialog dismissed, the list in the activity is refreshed directly.
I've been thinking of using a listview but listviews are only horizontal OR vertical but in this case I kind of need a mix of both.
Another idea was to delete the layout containing all the linearlayouts (all the list) when a new fruit was added, and then take my database to create all the linearlayouts again. But dynamically I don't think it will work, the refresh won't be done (?)
My last idea was to create a fragment and use my database in the onCreateView method to display every elements. And to refresh it, I'll just detach and attach again the fragment to the activity each time I add a new element.
I don't think my ideas are the optimal or even a correct way to do it, I've been struggling with it for a while. If you have any suggestions or ideas to help me, it would be great :)

Parse different data through the activity in the same activity

I am building an E-Commerce App and I have an activity showing image slider, description and related items, and in image slider I have put an arrow to change the product on the arrow click I want to be in the same activity but data should be different.How should I do that need your help guys.
You should try doing it by urself in one of the many ways its possible to. Then we could provide some help with your idea or show you better solution. I think you are looking for RecyclerView (https://developer.android.com/guide/topics/ui/layout/recyclerview). It lets you show some similar views but with different data inside. Also as an item inside RecyclerView you can try CardView.
Using only RecyclerView you can also use:
https://stackoverflow.com/a/46084182/8713068
You can also search for a library that has everything you want inside already implemented. For example the first library that came out after i typed it in google : https://github.com/Ramotion/cardslider-android.

JavaFx ListView for load Messages in chat application

i wanna write a chat app with a listview for messages item.
it's load messages at top and bottom of listview.
i want when messages added at top and bottom of listview scrollbar doesn't move.
(maybe this is because of javafx doesn't support 'cells of different lengths').
Try check ScrollTo Method tabWiew also ScrollTo Method ListView you just tell witch index should be showed always

How can i change the List XML via a swipe gesture

at the moment i'm trying to write an app which has a listview, and if i swipe especially left the listitem switches to another xml like it's used in the twitter app.
Especially i have a list of items only with some text and when i swipe left on a single item it changes to an other item (via a xml-file) especially with some buttons or anything else.
I hope anyone, has an idea how i can do this?
Thanks.
I have seen this done using a Gallery set to fill_parent. Care has to be taken to allow child views to pass on touch events appropriately for swiping to work. Note that Gallery is a subclass of ViewGroup.
EDIT: see comment below, i should've checked the twitter app first!

Categories

Resources