alertdialog

How to use and style new AlertDialog from appCompat 22.1 and above

匿名 (未验证) 提交于 2019-12-03 01:32:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to migrate from default android AlertDialog to the new one included in appCompat-22.1 So far I understand you only have to import android.support.v7.app.AlertDialog package in order to use it. But how can I style it? For example change the positive/negative button colors, title color, message color and background color? 回答1: When creating the AlertDialog you can set a theme to use. Example - Creating the Dialog AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.MyAlertDialogStyle); builder.setTitle(

How to implement a custom AlertDialog View

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In the Android docs on AlertDialog , it gives the following instruction and example for setting a custom view in an AlertDialog: If you want to display a more complex view, look up the FrameLayout called "body" and add your view to it: FrameLayout fl = (FrameLayout) findViewById(R.id.body); fl.add(myView, new LayoutParams(FILL_PARENT, WRAP_CONTENT)); First off, it's pretty obvious that add() is a typo and is meant to be addView() . I'm confused by the first line using R.id.body. It seems that it's the body element of the AlertDialog ... but

Missing buttons on AlertDialog | Android 7.0 (Nexus 5x)

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to create an AlertDialog but the buttons are not showing. Only seeing this issue in Android 7.0: final AlertDialog . Builder builder = new AlertDialog . Builder ( this ); builder . setTitle ( "This app needs location access" ); builder . setMessage ( "Please grant location access so this app can detect beacons." ); builder . setPositiveButton ( android . R . string . ok , null ); builder . setOnDismissListener ( new DialogInterface . OnDismissListener () { @Override @TargetApi ( Build . VERSION_CODES . M ) public void

Crash in AlertDialog builder when android suport library updated to 24

匿名 (未验证) 提交于 2019-12-03 00:56:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The code was working fine before, but when I updated support library to 24, It crashes when displaying alert dialog. Couldn't find any help as it is updated recently. Code: AlertDialog.Builder builderSingle; builderSingle = new AlertDialog.Builder(mContext); //set buttons and title code builderSingle.show(); Logcat: And the support libraries are: compile('com.android.support:recyclerview-v7:24.0.0') { exclude group: 'com.android.support', module: 'support-v4' } compile('com.android.support:support-v4:24.0.0') { force = true } compile 'com

how to achieve something like “finish” in a non-activity class in android?

匿名 (未验证) 提交于 2019-12-03 00:54:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: This dialog asks whether you want to install some other app...so when onclicked no button it must go back to the previous screen downloadDialog . setNegativeButton ( stringButtonNo , new DialogInterface . OnClickListener () { public void onClick ( DialogInterface dialogInterface , int i ) { finish (); } }); this gives the error: The method finish() is undefined for the type new DialogInterface.OnClickListener(){} how can i achieve what i wanted??? package com . Android . barcode ; import android . app . Activity ; import android .

Android 滚动时间选择器

匿名 (未验证) 提交于 2019-12-03 00:43:02
显示效果一般般 , 做个参考吧 布局文件 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="10dip" > <TimePicker android:timePickerMode="spinner" android:id="@+id/time_picker" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_gravity="center" > </TimePicker> </LinearLayout> 以上是 时间选择的布局文件,很简单 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http:/

弹框(AlertDialog)和提示信息Toast字体大小颜色设置

匿名 (未验证) 提交于 2019-12-03 00:14:01
一、 AlertDialog: AlertDialog . Builder builder = new AlertDialog . Builder ( getActivity ()); builder . setTitle ( "温馨提示" ); builder . setMessage ( "是否进行下一个病人?" ); builder . setPositiveButton ( "是" , new DialogInterface . OnClickListener () { @Override public void onClick ( DialogInterface dialogInterface , int i ) { //处理你的操作 } }); builder.setNegativeButton("否", null); AlertDialog dialog = builder.create(); dialog.show(); //弹框设置字体颜色 dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.BLUE); dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(Color.BLUE); try { /

弹框(AlertDialog)和提示信息Toast字体大小颜色设置

女生的网名这么多〃 提交于 2019-12-01 02:26:53
一、 AlertDialog: AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("温馨提示"); builder.setMessage("是否进行下一个病人?"); builder.setPositiveButton("是", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //处理你的操作 } }); builder.setNegativeButton("否", null); AlertDialog dialog = builder.create(); dialog.show(); //弹框设置字体颜色 dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.BLUE); dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(Color.BLUE); try { //获取mAlert对象 Field mAlert = AlertDialog

作业五

孤者浪人 提交于 2019-11-30 12:09:38
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:id="@+id/rt1" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.beijing.MainActivity" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello

第五次作业

我的梦境 提交于 2019-11-30 12:09:17
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/rl1" tools:context=".MainActivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮" android:textSize="39sp" android:background="#66cccccc" android:layout_centerVertical="true" android:layout_centerHorizontal="true" android:onClick="test" /><