啊塔

导航

随笔分类 -  我的Android自学笔记

成功人士在于他的坚持;
Android在非UI线程中显示Toast
摘要:[java] view plaincopyprint?publicvoidshowToast(Stringmsg){Looper.prepare();Toast.makeText(getApplicationContext(),msg,Toast.LENGTH_SHORT).show();Loope... 阅读全文

posted @ 2014-11-03 11:22 啊塔 阅读(1352) 评论(0) 推荐(0)

阻止Toast多次弹出
摘要:我们在使用的Toast是时候是直接调用它的静态方法Toast.makeText(this, "显示单次", Toast.LENGTH_SHORT).show()每次都去执行 Toast.makeText(this, "显示单次", Toast.LENGTH_SHORT).show()相当于每次都实例化了一次Toast对象因此多次点击它就会多次的显示解决的办法就是只实例化一次;Toast toast=null;public void toastShow(){ if (toast==null) { toast=Toast.makeText(this, &qu 阅读全文

posted @ 2013-07-19 13:58 啊塔 阅读(657) 评论(0) 推荐(0)

点击空白区域隐藏软键盘
摘要:flipperview=(LinearLayout) findViewById(R.id.flipperview01); flipperview.setOnTouchListener(touchListener);OnTouchListener touchListener=new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub Log.i("scro... 阅读全文

posted @ 2013-07-17 10:20 啊塔 阅读(323) 评论(0) 推荐(0)

VirtualBox Android x86 网络配置
摘要:声明:测试采用的网络是公司的内部网络VirtualBox Android -X86 的安装网络上很多,找了一个图解算是比较清晰的http://blog.sina.com.cn/s/blog_546629d70100z75a.htmlAndroid -X86 官网下载地址 http://code.google.com/p/android-x86/downloads/list好了现在开始讲解网络配置在配置之前建议你先看一下此篇文章http://www.crifan.com/virtualbox_network_related_settings_nat_bridged_ip_nic/(1)网络地址转 阅读全文

posted @ 2013-07-16 11:09 啊塔 阅读(5340) 评论(1) 推荐(0)

java.lang.NoClassDefFoundError: com.mobclick.android.MobclickAgent
摘要:java.lang.NoClassDefFoundError: com.mobclick.android.MobclickAgent在刚开始的时候我也是通过网上查找了很多资料网上的一些解决办法(1)http://www.xuephp.com/main/detail.php?cid=36441在.cl... 阅读全文

posted @ 2013-07-15 15:55 啊塔 阅读(874) 评论(0) 推荐(0)

自定义AutoCompleteTextView
摘要:网上找到的都是同ArrayAdapter一起使用的,有时候需要自定义风格,咋办?follow me! 看上图,实现了清空输入框内容和删除Item功能。 其实使用AutoCompleteTextView就得实现过滤器Filterable,你得告诉它怎么过滤。由于ArrayAdapter已经帮我们实现了Filterable接口,所以我们很容易忽略这个,以为AutoCompleteTextView用起来很简单。如果你使用的是BaseAdapter呢?当然,事实上也不难,只要让它也实现Filterable接口就可以了。 下面是源码: 实现自定义的Adapter import java.util.Ar. 阅读全文

posted @ 2013-07-02 13:12 啊塔 阅读(436) 评论(0) 推荐(0)

Android自定义对话框(Dialog)位置,大小
摘要:代码:package angel.devil;import android.app.Activity;import android.app.Dialog;import android.os.Bundle;import android.view.Gravity;import android.view.Window;import android.view.WindowManager;public class DialogDemoActivity extends Activity { /** Called when the activity is first created. */ @O... 阅读全文

posted @ 2013-07-01 12:54 啊塔 阅读(255) 评论(0) 推荐(0)

自定义对话框 Dialog
摘要:myDialog代码import android.app.Activity;import android.app.Dialog;import android.content.Context;import android.os.Handler;import android.view.Display;import android.view.LayoutInflater;import android.view.View;import android.view.View.OnClickListener;import android.view.Window;import android.view.Win 阅读全文

posted @ 2013-07-01 12:07 啊塔 阅读(373) 评论(0) 推荐(0)

Android获取系统的时间
摘要:Calendar c=Calendar.getInstance();mYear=c.get(Calendar.YEAR);mMonth=c.get(Calendar.MONTH);mDay=c.get(Calendar.DAY_OF_MONTH);mHour=c.get(Calendar.HOUR_OF_DAY);mMinute=c.get(Calendar.MINUTE);long time=System.currentTimeMillis();//取得系统的时间 单位是毫秒 阅读全文

posted @ 2013-06-13 15:58 啊塔 阅读(154) 评论(0) 推荐(0)

ListView 在代码里设置margin
摘要:ListView在代码里设置layout_marginTop、layout_marginLeft、layout_marginRight、layout_marginBottomListView lst=getListView();LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); params.setMargins(0, 0, 0, 0); //left,top,right,bottom ... 阅读全文

posted @ 2013-06-13 14:16 啊塔 阅读(734) 评论(0) 推荐(0)

android 获取屏幕高度和宽度 的方法
摘要:android 获取屏幕高度和宽度 的方法2011-07-12 16:05:06|分类: android |标签: |字号大中小订阅我们需要获取Android手机或Pad的屏幕的物理尺寸,以便于界面的设计或是其他功能的实现。下面就介绍讲一讲如何获取屏幕的物理尺寸下面的代码即可获取屏幕的尺寸。在一个Activity的onCreate方法中,写入如下代码:DisplayMetrics metric = new DisplayMetrics();getWindowManager().getDefaultDisplay().getMetrics(metric);int width = metric.w 阅读全文

posted @ 2013-04-28 13:46 啊塔 阅读(257) 评论(0) 推荐(0)

android Paint
摘要:android Paint属性/***Paint类介绍**Paint即画笔,在绘图过程中起到了极其重要的作用,画笔主要保存了颜色,*样式等绘制信息,指定了如何绘制文本和图形,画笔对象有很多设置方法,*大体上可以分为两类,一类与图形绘制相关,一类与文本绘制相关。**1.图形绘制*setARGB(inta,intr,intg,intb);*设置绘制的颜色,a代表透明度,r,g,b代表颜色值。**setAlpha(inta);*设置绘制图形的透明度。**setColor(intcolor);*设置绘制的颜色,使用颜色值来表示,该颜色值包括透明度和RGB颜色。**setAntiAlias(boolea 阅读全文

posted @ 2013-04-27 10:29 啊塔 阅读(174) 评论(0) 推荐(0)

android中LayoutInflater的使用
摘要:Inflater英文意思是膨胀,在Android中应该是扩展的意思吧。LayoutInflater的作用类似于 findViewById(),不同点是LayoutInflater是用来找layout文件夹下的xml布局文件,并且实例化!而 findViewById()是找具体某一个xml下的具体 widget控件(如:Button,TextView等)。(0)她可以有很多地方可以使用,如BaseAdapter的getView中,自定义Dialog中取得view中的组件widget等等。它的用法有2种:复制到剪贴板Java代码view plaincopy to clipboardprint? . 阅读全文

posted @ 2013-01-18 14:18 啊塔 阅读(181) 评论(0) 推荐(0)