AlertDialog错误

Unable to add window token null is not for an application 
  AlertDialog.Builder localBuilder = new AlertDialog.Builder(Service_Activity.this);// 这里使用getApplicationContext() 报错 必须使用当前activity。

-----------------------------------------------------------------------------------------------------------------------------------------------------------

textView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                AlertDialog.Builder localBuilder = new AlertDialog.Builder(Service_Activity.this);
                 localBuilder.setTitle("编辑地址").setIcon(R.mipmap.bianji);                  //
                final LinearLayout layout_alert= (LinearLayout) getLayoutInflater().inflate(R.layout.layout_alertservicejiekou, null);
                 localBuilder.setView(layout_alert);
                localBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener()
                {
                    public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
                    {              // 这里使用(LinearLayout) getLayoutInflater().inflate(R.layout.layout_alertservicejiekou, null).findViewByid(R.id.edit1)             // .getText().toString()是得不到数据的
                        EditText edit1= (EditText) layout_alert.findViewById(R.id.edit1);
                        System.out.println("***out"+edit1.getText().toString());
                        textView1.setText(edit1.getText().toString().trim());

                    }
                }).setNegativeButton("取消", new DialogInterface.OnClickListener()
                {
                    public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
                    {

                    }
                }).create().show();
时间: 2024-08-17 10:13:52

AlertDialog错误的相关文章

android AlertDialog 错误 OnClickListener 报错

写dialog一直报错 The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder is not applicable for the arguments (String, new   View.OnClickListener(){}) builder.setPositiveButton("Don't Remind", new OnClickList

Android Framework 记录之二

原文地址:http://blog.csdn.net/banketree/article/details/24982021 接着上次的记录,续写. 23.services目录 文件 描述 class AlarmManagerService extends IAlarmManager.Stub { //定时管理服务 public class AppOpsService extends IAppOpsService.Stub {  // 程序选项服务 public class AppsLaunchFa

framework结构

记录 1.下载源码,目录如下: 2.Android系统的层次如下: 3.项目目录简单分析如下: 4.telphony目录 文件 描述 CellIdentityCdma //描述电信通信标识 CellIdentityGsm 描述移动通信标识 CellIdentityLte 描述3G通信标识 CellIdentityWcdma 描述联通通信标识 CellInfo 手机信息(什么网络.是否已注册.记录时间) class CellInfoCdma extends CellInfo 电信通信手机信息 Ce

Android中的AlertDialog遇到的错误

public void showAddIPCDialog() { Log.i("ssssssssss","wwwwwwwwww"); LayoutInflater inflater = this.getActivity().getLayoutInflater(); Log.i("ssssssssssinflater",inflater+"");//错误 // final View layout = inflater.infla

弹出AlertDialog的时候报You need to use a Theme.AppCompat theme (or descendant) with this activity错误

今天遇到一个bug,用百度地图的时候,我对上面的标注设置了点击监听,设置的相应的反应是弹出一个AlertDialog 记录一解决bug的历程 但是Dialog却没有弹出来,一看AS下面,报了这错,起初我看我gradle.app里面 implementation 'com.android.support:appcompat-v7:24.2.1' 这句话是红色,我以为是包冲突,但是上午我安卓课上我明明也是用的这个,是可以正常弹出Dialog的 然后我查了查网上, 一种说法:很多说把Activity的

android开发之AlertDialog点击按钮之后不消失

最近有这样一个需求,我需要用户在一个弹出框里输入密码来验证,验证成功当然好说,但是如果验证失败则需要把alertdialog的标题改为"密码错误,请重新输入",并且这个alertdialog还不能消失,要等待用户继续输入. 那么怎么实现点击确定或者取消按钮之后dialog不消失呢? // 不关闭dialog try { // 不关闭 Field field = dialog .getClass() .getSuperclass() .getDeclaredField( "mS

[Android] AlertDialog获取网上天气并显示各城市天气

    最近帮同学做android百度地图,其中涉及到定位城市天气功能.才知道自己技术非常的一般,还有很多东西需要学习,同时需要回归到我研究生的方向--数据挖掘.同时又见识到了一位叫柳峰的大神,推荐大家去看看他的文章,好像他还是贵州的老乡.博文地址:http://blog.csdn.net/lyq8479/ 言归正传,我主要通过两种方法实现: 1.第一种方法是通过调用中国天气网信息实现的,它的思想是通过查询静态数据库中个城市对应的WeatherCode,在通过访问中国天气网获取JSON格式数据显

Retrofit+RxJava 优雅的处理服务器返回异常、错误

开始本博客之前,请先阅读: Retrofit请求数据对错误以及网络异常的处理 异常&错误 实际开发经常有这种情况,比如登录请求,接口返回的 信息包括请求返回的状态:失败还是成功,错误码,User对象等等.如果网络等原因引起的登录失败可以归结为异常,如果是用户信息输入错误导致的登录失败算是错误. 假如服务器返回的是统一数据格式: /** * 标准数据格式 * @param <T> */ public class Response<T> { public int state;

Android Studio:You need to use a Theme.AppCompat theme (or descendant) with this activity. AlertDialog

有两个解决办法: 1. 把我们当前的Activity所继承的ActionBarActivity,改为继承Activity(android.app.Activity). 2.我出现错误的地方是因为使用了AlertDialog,发现我导入的android.support.v7.app.AlertDialog,然后我就改为导入android.app.AlertDialog就成功了.