Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom font type and color in AlertDialog

 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I just want to know how can i display custom font-color, font-type and icon (all three is in different Dialog)

I have attached 3 images in this post

Image 1 is icon on left side
Image 2 is all text lines has different font
Image 3 is all text lines has different color.

Also is that possible play ringtone in the AlertDialog?

I know all those are already done, but i want to know how can i do.

I really appreciate for any idea and guidance.

Regards
draw1.png
[Thumbnail for draw1.png]
Alertdialog with icon
draw2.png
[Thumbnail for draw2.png]
Alertdialog with font
draw3.png
[Thumbnail for draw3.png]
Alertdialog with color
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the API for AlertDialog: http://developer.android.com/reference/android/app/AlertDialog.html
In the API is a link to an API Guide which explains more. The AlertDialog can be used to show a List of things, and exposes a ListView. Which means you can provide what you want to the ListView. See http://developer.android.com/guide/topics/ui/layout/listview.html for a guide on how to use them. The only difference here is you would not be creating a new ListView, you would be getting the one AlertDialog provides.

As for playing a ringtone in an alert dialog - yes, see http://developer.android.com/reference/android/media/RingtoneManager.html and http://developer.android.com/reference/android/media/Ringtone.html, the first has a static method to get the Ringtone, which you then use to play. You can do this from the event method that opens the dialog or in the click events triggered when you select an item in the list. If your intent is to make a tool to let users select a Ringtone, you might consider looking up the Ringtone Picker (you can call it using an intent to the RingtoneManager.ACTION_RINGTONE_PICKER uri, it will show a standard dialog picker and provide results. There are numerous examples around the web including how to add your own ringtones to the list and how to store the selected result as the default ringer...)
 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Steve
Thanks for answer.
I have checked API guide and i didn't understand anything.
Sometimes i am really missing PHP manual page. It is so easy to read, well explained and clear samples.
I don't know why but i found Java/Android API guide just useless.

Anyway, I think i misled you i forgot to mention that all of fonts, thumbnail icons... etc are located in the assets folder.

So, what i am trying to do is play ringtone in the assets folder when user click the Play icon in the Alertdialog.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right. So, you should put your custom Font(s) in the assets folder and use Typeface to import it. Then when you make the layouts for the ListView items (see the API guide I provided earlier) you set the View's typeface using the one you loaded from assets.

Colors can/should be defined as a resource, (in res/values/colors.xml) then can also be set on the View you use to display in the ListView. See http://developer.android.com/guide/topics/resources/more-resources.html.

Icons can be stored in the res/drawables/ folder. Read http://developer.android.com/training/multiscreen/screendensities.html, after which you should understand you should provide multiple versions of the icons to work on different screen densities. It is possible to load the icons from the assets folder, but not optimal so you should avoid it - put them where they belong in the res/drawables folder(s).
 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your answer.
I have followed your suggestion and cleaned up my project(colors are color.xml, icons are drawable ...)

Now i can reach my items much easier than before.

Thank you very much again.

Have a great day.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, I am glad I could help. Happy coding
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic