# StyledDialogs for Android
This library makes styling and using dialogs _a piece of cake_.
![Screenshot of the dialogs](graphics/screenshot-small.png)
Features:
- Compatible with Holo style and **Android Design Guidelines**
- Change style for all dialogs only by changing a **few color resources**
- Same look for **Android 2.2+**
- **Same API** as native Android DialogFragments
- `SimpleDialogFragment` class, which makes displaying simple dialogs a **one line of code**
## How to include it in your project:
With Gradle:
```groovy
compile 'eu.inmite.android.lib:android-styled-dialogs:1.1.2@aar'
```
With Maven:
```xml
<dependency>
<groupId>eu.inmite.android.lib</groupId>
<artifactId>android-styled-dialogs</artifactId>
<version>1.1.2</version>
<type>apklib</type>
</dependency>
```
Manually:
- clone the project
- add it as library project in your IDE
- include latest support library
## How to style all dialogs:
Add following into your application theme:
```xml
<item name="sdlDialogStyle">@style/DialogStyleLight.Custom</item>
```
or
```xml
<item name="sdlDialogStyle">@style/DialogStyleDark.Custom</item>
```
Define your dialog style, example for light theme:
```xml
<style name="DialogStyleLight.Custom">
<!-- anything can be left out: -->
<item name="titleTextColor">@color/dialog_title_text</item>
<item name="titleSeparatorColor">@color/dialog_title_separator</item>
<item name="messageTextColor">@color/dialog_message_text</item>
<item name="buttonTextColor">@color/dialog_button_text</item>
<item name="buttonSeparatorColor">@color/dialog_button_separator</item>
<item name="buttonBackgroundColorNormal">@color/dialog_button_normal</item>
<item name="buttonBackgroundColorPressed">@color/dialog_button_pressed</item>
<item name="buttonBackgroundColorFocused">@color/dialog_button_focused</item>
<item name="dialogBackground">@drawable/dialog_background</item>
</style>
```
## How to create simple dialogs:
Easy:
### Dialog with a simple message and Close button:
```java
SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setMessage(R.string.message).show();
```
### Dialog with a title, message and Close button:
```java
SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setTitle(R.string.title).setMessage(R.string.message).show();
```
### Dialog with a title, message and two buttons:
```java
SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setTitle(R.string.title).setMessage(R.string.message).setPositiveButtonText(R.string.positive_button).setNegativeButtonText(R.string.negative_button).show();
```
### How to react on button press in your Activity/Fragment:
Simply implement interface `ISimpleDialogListener` in your Activity/Fragment. Listener's callbacks have `requestCode` parameter - you can use it if you have more dialogs in one Activity/Fragment.
For Fragments use setTargetFragment() method in the builder.
### How to react on cancelling the dialog:
Implement interface `ISimpleDialogCancelListener` in your Activity/Fragment.
## How to create all other DialogFragments:
Extend `BaseDialogFragment` and look at demo app implementation. It shows two types of those implementations:
- `FavoriteCharacterDialogFragment` shows a list in the dialog using extending `BaseDialogFragment`
- `JayneHatDialogFragment` shows a custom view in the dialog using extending `SimpleDialogFragment`
## Wishlist
The library could be improved with more common dialogs. Pull requests are encouraged!
### Possible candidates:
- date picker (spinners or calendar)
- time picker
- edittext dialog
- password dialog
- ...
## Why 'Dialogs'?
<img src="http://img.radio.cz/pictures/osobnosti/cimrman_jarax.jpg" width="70" align="right"/>
Theodor Dialogs was a famous Czech painter, uncle of [Jára Cimrman](http://en.wikipedia.org/wiki/J%C3%A1ra_Cimrman). Jára Cimrman was a playwright, philosopher, inventor, teacher, poet, mathematician and more but he lacked painting skills. That's why Theodor was helping him with many projects. Just like Android and this library do.
See [**our other Czech personalities**](http://inmite.github.io) who help with [#AndroidDev](https://plus.google.com/s/%23AndroidDev).
没有合适的资源?快使用搜索试试~ 我知道了~
android-styled-dialogs 可自定义样式的dialog
共66个文件
xml:30个
png:14个
java:10个
需积分: 9 7 下载量 16 浏览量
2015-09-21
14:08:32
上传
评论
收藏 431KB ZIP 举报
温馨提示
android-styled-dialogs 可自定义样式的dialog对话框源码0分下载了
资源推荐
资源详情
资源评论
收起资源包目录
android-styled-dialogs 可自定义样式的dialog.zip (66个子文件)
android-styled-dialogs-master
pom.xml 5KB
gradle.properties 605B
maven_push.gradle 2KB
library
pom.xml 3KB
gradle.properties 91B
src
main
res
values-v11
sdl__theme.xml 504B
drawable-hdpi
sdl_background_light.9.png 1KB
sdl_background_dark.9.png 307B
drawable-xhdpi
sdl_background_light.9.png 2KB
sdl_background_dark.9.png 366B
color
sdl_primary_text_holo_dark.xml 1KB
sdl_primary_text_holo_light.xml 1KB
values
sdl__colors.xml 2KB
sdl__attrs.xml 941B
sdl__dimens.xml 1KB
sdl__theme.xml 6KB
sdl__ids.xml 215B
sdl__strings.xml 108B
drawable-mdpi
sdl_background_light.9.png 944B
sdl_background_dark.9.png 219B
layout
dialog_part_list.xml 172B
dialog_part_title.xml 395B
dialog_part_message.xml 314B
dialog_part_button_panel.xml 426B
dialog_part_button.xml 145B
dialog_part_progress.xml 437B
dialog_part_custom.xml 312B
dialog_part_datepicker.xml 178B
dialog_part_button_separator.xml 188B
java
eu
inmite
android
lib
dialogs
ISimpleDialogListener.java 957B
ProgressDialogFragment.java 4KB
SimpleDialogFragment.java 8KB
BaseDialogBuilder.java 2KB
BaseDialogFragment.java 15KB
ISimpleDialogCancelListener.java 801B
AndroidManifest.xml 214B
project.properties 585B
build.gradle 588B
graphics
screenshot-original.png 71KB
screenshot-small.png 57KB
.gitignore 465B
CHANGELOG.md 801B
demo
pom.xml 1KB
res
drawable-ldpi
ic_launcher.png 3KB
drawable-hdpi
ic_launcher.png 9KB
drawable-xhdpi
ic_launcher.png 14KB
jayne_icon.png 8KB
jayne_hat.png 215KB
values
colors.xml 1KB
strings.xml 897B
styles.xml 1KB
theme.xml 2KB
drawable-mdpi
ic_launcher.png 5KB
layout
item_list.xml 234B
item_jayne_hat.xml 253B
main.xml 2KB
src
eu
inmite
demo
dialogs
JayneHatDialogFragment.java 2KB
FavoriteCharacterDialogFragment.java 3KB
MyActivity.java 6KB
IFavoriteCharacterDialogListener.java 761B
project.properties 567B
AndroidManifest.xml 682B
README.md 4KB
settings.gradle 17B
LICENSE.txt 11KB
build.gradle 367B
共 66 条
- 1
资源评论
lkkl1977
- 粉丝: 4
- 资源: 201
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功