Android一些小技巧
1:设置选中图片的背景颜色
this.gridviewToolbar = (GridView) super.findViewById(R.id.gridviewbar);
this.gridviewToolbar.setSelector(new ColorDrawable(Color.TRANSPARENT));
2:通过屏幕的长度,宽度来定义控件的长宽
this.width = super.getWindowManager().getDefaultDisplay().getWidth()
/ this.menu_img.length;
this.height = super.getWindowManager().getDefaultDisplay().getHeight() / 8;
3:退出的对话框
private void exitDialog() {
Dialog dialog = new AlertDialog.Builder(this)
.setMessage("您确定要退出本程序吗?")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
LoginActivity.this.finish() ;
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).create();
dialog.show();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK) {
this.exitDialog() ;
}
return false ;
}
4:取消标题,必须在设置布局文件之前取消掉
super.requestWindowFeature(Window.FEATURE_NO_TITLE);
Android一些小技巧的更多相关文章
- Android Studio 小技巧/快捷键 合集
参考: http://jaeger.itscoder.com/android/2016/02/14/android-studio-tips.html 1. 书签(Bookmarks) 描述:这是一个很 ...
- android 编程小技巧(持续中)
first: Intent跳转一般存用于Activity类,可是若要在非activity类里跳转的话,解决方法是在startActivity(intent)前加mContext即上下文,终于为 ...
- android studio小技巧
1. 为了防止乱码,请将 android studio 右下角编码设置成 UTF-8 2. Ctri + Q 查看api 3 Ctri + Shift +U 大小写互换 4 Ctrl + Alt + ...
- 【Android Studio 小技巧】一键查看文件方法结构目录File Structure
看源代码的时候,如果可以查看class中的所有方法,可以提高效率.Android Studio 中可以使用快捷键一键显示所有方法的目录. Mac: command + fn + F12 (在mac中的 ...
- Android Studio 小技巧(2):AS中Button文字默认大写的问题
问题类型 设置Layout中添加一个Button <Button android:id="@+id/bt_showerror" android:layout_width=&q ...
- Android Studio 小技巧(1):如何导入AAR文件
1. 导入AAR.JAR文件 File- > New -> New Module 这样子AAR文件就导入了,然后在app中的build.gradle中做如下添加 dependencies ...
- android开发-小技巧篇(集合)
1.对于过多的控件,功能类似,数量又多的,可以用include方法.在实现应用中,可以把控件放入List集合中. private void initView() { // TODO Auto-gene ...
- Android调试小技巧(LogCat不输出、Log自动清空、install时timeout)
问题:有时候明明连接了设备,而LogCat却没有输出 解决方法:在device界面点一下对应设备,使其处于选中状态(它适用于查看手机文件不显示的情况) 问题:前面记录的Log看着看着突然被清空了 解决 ...
- Android Studio 小技巧
请参照http://blog.csdn.net/jdsjlzx/article/details/50689047 个人认为较有用: 30
随机推荐
- 简单实现http proxy server怎么实现?
原文:https://blog.csdn.net/dolphin98629/article/details/54599850 简单实现http proxy server怎么实现?
- 为Subline Text 3 添加支持ini文件语法高亮
转: http://lancelot.blog.51cto.com/393579/1783653 在Subline text 官网下载了Subline text 3 .不过发现没有对ini格式文件的语 ...
- [Git] Change the commit message of my last commit
Did you make a typo in your last commit message? No problem, we can use the git --amend command to c ...
- Springboot单元测试(MockBean||SpyBean)
转载:https://blog.csdn.net/maiyikai/article/details/78483423 本来要写springboot集成netty实现的,但是想起来单元测试没总结,那就趁 ...
- Android Studio 之 环境搭建
从网上整理的安装步骤及初次使用问题解决. 一.安装步骤 1.安装前确认JDK已经安装并配置好环境变量(要求JDK1.7以上的版本). 2.官网下载Windows安装包,网上下载的版本是android- ...
- Java 生成ZIP文件
public static byte[] fileToZip(){ ZipOutputStream append = null; ByteArrayOutputStream bos = new Byt ...
- j2ee数据库连接池配置大全
<!--web.xml begin--> <!--web.xml Spring ApplicationContext配置文件的路径 ,可使用通配符,多个路径用,号分隔 --> ...
- web ide
https://www.jianshu.com/p/339dff3da1fa https://www.eclipse.org/che/ https://github.com/Coding/WebIDE ...
- MySQL快速建立测试表
1:只要已经存在表结构的 第一种方式: CREATE TABLE T1 SELECT * FROM mysql.user ; 第二种方式: CREATE TABLE T2 LIKE mysql.use ...
- Android——代码中使用颜色值
android中设置颜色时,可以直接使用颜色值来设置: view.setBackgroundColor(Color.parseColor("#颜色值"));