[安卓学习小记]You need to use a Theme.AppCompat theme (or descendant) with this activity.
来源:互联网 发布:sql去重复列名 编辑:程序博客网 时间:2024/06/06 04:15
果然,实践才是真正出能力的方式初学安卓,看了一个星期的书,决定还是从登陆验证这些开始写起
button_register.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view) { Log.d("注册监听","进入"); //调用注册--暂不开放 Dialog alertDialog = new AlertDialog.Builder(MainActivity.this) //getParent()//getApplicationContext()????!!!!!! .setTitle("提示!") .setMessage("功能暂未开放!!!") .setPositiveButton("确定",null) .create(); try{ alertDialog.show(); }catch (Exception e){ Log.d("异常块","失败"); e.printStackTrace(); } } });
在这个代码块里面,一直给我报alertDialog.show();这句有问题。然后我加上了一个try-catch块。发现编译器给报了You need to use a Theme.AppCompat theme (or descendant) with this activity. 原因是AlertDialog.Builder()里面的参数应该是一个context(上下文对象)。但是不能通过getParent和getApplicationContext()获取解决的办法是AlertDialog.Builder(MainActivity.this) 里面的参数是Your_Activity.this
1 0
- [安卓学习小记]You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 关于“you need to use a theme.appcompat theme (or descendant) with this activity”错误
- Android开发~you need to use a theme.appcompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- 【Android】You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决
- you need to use a theme.appcompat theme (or descendant) with this activity 解决办法
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 报错 You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android Studio You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- 关于You need to use a Theme.AppCompat theme (or descendant) with this activity的问题
- django 使用mysql 出现的 No module named MySQLdb
- Delphi-将ListView内容导出到文件
- 五大常用算法之三:贪心算法
- HDU1873
- 杂物
- [安卓学习小记]You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 编号 枚举
- android和java中对线程的使用总结
- 路由器进行桥连的方法
- vb.net LINQ TO XML读写XML
- from one corner to another corner ,please get the shortest path numbers
- UVA-400 Unix ls
- 七月随笔
- 《web scraping with python》笔记--穿越网页表单与登录窗口进行采集