android chat listview with user profile picture - android

I have to implement a chat in android which should look like in the following image:
How to implement such a ui using listview and adapter?
The row_layout should contain only one message or all messages of one user including his avatar?
Think it should contain only one message, but where to inflate the profile picture for each user at the top of his messages?
Pease help with any suggestions.
Thanks in advance!

you need two layout for this,both consists from an ImageView and a ListView. The only difference between them will be the Gravity( one is Left the Other is Right). And in your out most ListView's getView method, return this two layout based on the data you have.

Related

How can I create this layout in android like any.do application?

I want to create a layout like the one in the pictures below:
Category
Things to be done
The first picture displays the categories PERSONAL,OFFICE,WORKOUT.
On clicking one of them,the things to be done under that category is displayed.
Any suggestions/sample code for the same? Thanks.
Use Expandable Lists and extendable Adapter

custom view for datavisualization

in my Android App I show the user some messages. Therfore I have Linearlayouts which contain a textview. Whenever the App receives a new message I add a LinearLayout to my page, set the LinearLayout's background to a custom one and then add the TextView to it in code. What I want to do is to create a custom View, which is basically the LinearLayout with a custom background and the textview in it. And/or a View which displays all the messages by itself.
What I want to achieve is that I only have to add one view to my XML-Layoutfile. In my code I then simply add all the messages to a property of the view and those messages are displayed automatically.
I hope you understand what I want to achieve.
Thank you for your help!
It sound like Andre Classen said a RecyclerView is maybe the best way for your. You can create custom layouts for different Cards, Rows, and display them.
Here you find more about the Recycler View with Official Tutorial.

how to create multiple textviews inside a fragment?

I am trying to create a fragment and inside that i want to create multiple textviews whoose text is set from the data retreived from the database(mysql).
And also i want to have the feature "refresh" by which the textviews are updated with recent data from the database.Iam trying to do that but iam not getting enough idea how to do it as iam new to android programming.
Please help me with this. thank you in advance and any suggestions are acceptable.
i.e
I have database of a person and i want to get his name and address from that,then in my activity i want to create a fragment that displays a name and address in separate textboxes and if address or name exceeds some length then i can press "more" to see left information
Consider using a ListView to populate data from the database, and a SwiperRefreshLayout to refresh it. Check these links for more info :
SwipeRefreshLayout
ListViews
The answer depends on what your app will do.
If you have a fixed number of TextViews, and the number won't change in the future or depending on the answer to the database query, you could simply stick to normal TextViews; if the number changes, I suggest using ListViews or ExpandableListViews.
Regarding the layout, you can create a normal layout using AndroidStudio's layout designer, and then inflate it to your view.
For the refresh, you can add a button that calls the method in which you fill the textviews/listviews.
Actually your question is too broad: if you want a more specific answer, you should edit it asking what you really need.

How do I create this type of chat layout in my application?

I am developing one chat application and i want to create a chat screen layout like following screen.
Currently I am using ListView for my chat texts but the problem is that to read the long chats I have to scroll down,my screen does not scrolls automatically.
I want this bubble kind of chat layout. How do I develop this kind of chat layout?
What you need here is a layout with a header and footer part, having as a main view a ListView.
This ListView should have a custom Adapter to show the message items.
To achieve this bubble-like display, your itemRenderer should be able to deal with states (fromMe - fromOther).
To have the bubbles, you should attach different backgroundDrawable (bubble 9patches pointing to the left and right) to different states.
If you have stuck somewhere, share the relevant code snippets and logcat output, so we can help you further.
try looking at this for creating a custom view for listView.
I would create a parent View and an incoming one and outgoing one that inherit from it and change color and gravity according to the one they are.
You need the following:
A ListActivity, ListView XML Layout.
BaseAdapter which ListActivity Uses.
BaseAdapter getView will inflate each Row.
In Each Row have a row View with you bubble images and your chat text.
In Listview Footer have a EditText View to Type Chat.
Use these for reference:
http://developer.android.com/reference/android/app/ListActivity.html
http://developer.android.com/reference/android/widget/BaseAdapter.html
OK if I understand you correctly all you need to do is implement auto-scroll for the Listview.
if so then try calling smoothScrollToPosition each time something is added. I don't know what your class looks like but maybe can run something like this (pseudo code)
customListview.addNewChat(...);
customListView.smoothScrollToPosition(customListView.getCount());

Custom Adapter for Gallery View in Android

hi i want to split my gallery with 5 images in 2 rows.
Please let me know how to do this in android using Gallery View & custom adapter for Gallery view.
Is there any sample code available please share it, i have already checked the previous posts in this site.
Thanks
If you still need this and Pagination instead of scroll will work for you, you might look at: https://github.com/sfarooq/PaginatedGallery
I designed it using ViewPager so you can manipulate the adapter to send any kind of views you want including two row views.
If you must use scrolling galleries you could implement two separate gallery in a vertical orientation and send touch events from each to the other.

Categories

Resources