1 Star 0 Fork 2

mldeng/android-styled-dialogs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

StyledDialogs for Android

This library makes styling and using dialogs a piece of cake.

Screenshot of the dialogs

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:

compile 'eu.inmite.android.lib:android-styled-dialogs:1.1.2@aar'

With Maven:

<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:

<item name="sdlDialogStyle">@style/DialogStyleLight.Custom</item>

or

<item name="sdlDialogStyle">@style/DialogStyleDark.Custom</item>

Define your dialog style, example for light theme:

<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:

SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setMessage(R.string.message).show();

Dialog with a title, message and Close button:

SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setTitle(R.string.title).setMessage(R.string.message).show();

Dialog with a title, message and two buttons:

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'?

Theodor Dialogs was a famous Czech painter, uncle of Jára 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 who help with #AndroidDev.

空文件

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/mldeng/android-styled-dialogs.git
git@gitee.com:mldeng/android-styled-dialogs.git
mldeng
android-styled-dialogs
android-styled-dialogs
master

搜索帮助