android Gmail app like List View with a letter in icon
Solution 1
I use the TextDrawable library. The point is this: when you have the user's photo, you display the photo, otherwise the letter. So it's easier to only have one ImageView
instead of having an extra TextView
on top of it.
Solution 2
Although I used TextDrawable library as suggested by @Eugen Pechanec , I would like to add another librray that I found called RoundedLetterView
RoundedLetterView like the one in Android 5.0 Contacts app
Solution 3
I did it by setting TextView's Background any random color that I already defined in color.xml. If I find the image in adapter image is displayed and if I don't find an image random color is set as textview background with BIG text in it. If you need any shape like circle oval etc then create xml in drawable. Use that xml as a background of TextView. I hope it helps.
Solution 4
For the Swipe to delete listview you can use the link https://github.com/romannurik/android-swipetodismiss and for the icon , a TextView with same width and height is enough .
Solution 5
Check out these Material-colored letter icons, pre-generated as 512x512
PNG files:
dmSherazi
I am Electronics engineer Working in the Embedded Electronics filed and PCB design Field My Blog About.me
Updated on July 26, 2022Comments
-
dmSherazi almost 2 years
I am looking for a solution like the emails list in gmail's android app, I want a list with swipe to delete and to have title and an icon with the first character of the title. in my application this will be used to show some names in the app from a database table, so there will be this icon like in the gmail app with the first letter of name and then the name next to it. Swiping will give an option to delete.
here is the screenshot for reference (I would be using just the title ,the icon on left and time ! )
UPDATE
Now I am planning to use TextDrawable as EUGEN advised. Now I have this issue, The Sample adapter provided in sample folder of the library, uses listarry as dataset
private List<ListData> mDataList = Arrays.asList( new ListData("Iron Man"), new ListData("Captain America"), new ListData("James Bond"), new ListData("Harry Potter"), new ListData("Sherlock Holmes"), new ListData("Black Widow"), new ListData("Hawk Eye"), new ListData("Iron Man"), new ListData("Guava"), new ListData("Tomato"), new ListData("Pineapple"), new ListData("Strawberry"), new ListData("Watermelon"), new ListData("Pears"), new ListData("Kiwi"), new ListData("Plums") );
I have to use data in the form of string array. I am new to list arrays and adapters so I need help!
-
dmSherazi over 9 yearsThanks for your answer.. Can you help me in coding for the list-view adapter model. I am new to list views and android in genral
-
dmSherazi over 9 yearshow to pragmatically set the the character for the icon type of text view ?
-
Krish over 9 yearsYou can use yourIconTextView.settext(theFirstChar); some thing like this in your adapters getView() method.
-
dmSherazi over 9 yearsAwesome, exactly what I needed! Thanks
-
dmSherazi over 9 years@ EUGEN I am trying to use it but having difficulties in using it with my data from string array , Can you please provide an example to use it !
-
Eugen Pechanec over 9 yearsThe "How to use" section of source seems pretty verbose. What exactly is troubling you?
-
Eugen Pechanec over 9 yearsCan we use some other means of communication (ie. email)? This goes beyond the original topic.
-
dmSherazi over 9 yearsthis is my email [email protected] , we can have a chat as well on hangouts ! It would be a great help!
-
Bruce almost 8 yearsGlad that I found this, this is exactly what I needed, the size can even be customized easily, brilliant! Thanks for sharing this!