随笔分类 - Android问题
摘要:当识别SDCard的时候String filePath = null; String state = Environment.getExternalStorageState(); if (state.equalsIgnoreCase(Environment.MEDIA_MOUNTED)) {//当SDCard挂载时 }else{//当SDCard没有挂载时 } 如果没有就下到了/data/data/app_file/目录下面去了,但安装涉及到权限问题:try {...
阅读全文
摘要:我在ListView中用BaseAdapter的getView()方法加载适配器,每个Item里有一个TextView和一个EditText,当我在第一个EditText里面输入数据,比如1234时,同时会在第八个EditText中也出现1234,同样的,如果我在第二个EditText中输入1234,那么在第九个EditText中就会出现1234,以此类推,不知道是怎么回事,下面有解决方法和原因ListView 为了避免浪费内存 只是用了 一屏幕的 ListItem所以每次 getView 的 时候会 使用 使用这一屏幕中的 其中一个 item所以在adapter 的getView方法中 必须
阅读全文
摘要:前几天因为项目的需要,要在一个ListView中放入另一个ListView,也即在一个ListView的每个ListItem中放入另外一个ListView。但刚开始的时候,会发现放入的小ListView会显示不完全,它的高度始终有问题。上网查了下,发现别人也有遇到这样的问题,而大多数人都不推荐这样的设计,因为默认情况下Android是禁止在ScrollView中放入另外的ScrollView的,它的高度是无法计算的。 又搜索了一下,发现有StackOverflow上的牛人已经解决了这个问题,经过试验发现是可以解决问题的,它的思路就是在设置完ListView的Adapter后,根据ListVie
阅读全文
摘要:我需要改变CheckBox的大小(我通过加背景图片的方式,视觉上已经小了,但是还是占默认大的空间),并且我要改变CheckBox和后面文字的间距,怎么修改styles.xml?解决方法:1.设置android:paddingLeft="25dip",就可以了,我刚测试过。2.设置checkbox的背景图片。系统默认的给checkbox加的有一个透明的背景。处理过的
阅读全文
摘要:今天写一个Service时,在manifest文件的<service>标签发现了这个警告<service android:name="SendService"> <intent-filter> <action android:name="com.oem.OEMSendService.SENDMAIL" /> </intent-filter> </service> 查了下api,终于发现一些端倪原因:这是一个可以被外部访问的service,需要使用权限来限制外部访问解决方法:1.添加a
阅读全文
摘要:Button或者ImageButton , 一旦使用,会取消掉父类的onClickListener ; 这个相当糟糕且麻烦。有个办法可以得到大部分人想要的需求:在按钮点击相应按钮功能,在按钮之外响应父类的onClickListener;1 . 在button上使用onClickListener2 . 在button上,setFocusable(false) ; 这里相当稀奇的是,叫做setFocusable,而不是setClickable,可能上来不是很好理解。3 . 在父类使用onItemClickListener
阅读全文
摘要:父RelativeLayout 套 子RelativeLayout ,并且以.9的图做背景,高度是wrap_content ;如果子View设置layout_alignParentBottom="true"则会出现.9的背景在高度上无限拉伸,而且并不贴着parent的底;layout_alignParentBottom="@id/hisParent"则不会导致拉伸。
阅读全文
摘要:This answer has 2 parts 1) its not how much images the screen has, but being carefull on cleaning everything up when finishing the activity 2) Android dev site (http://developer.android.com/resources/articles/future-proofing.html) Technique to Avoid, #3: Going Overboard with Layouts Due to changes i
阅读全文
Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity
摘要:Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?Context中有一个startActivity方法,Activity继承自Context,重载了startActivity方法。如果使用Activity的startActivity方法,不会有任何限制,而如果使用Context的start
阅读全文
摘要:This question is over a year old and is definitely long and complicated and the English language is difficult to understand. However, it still probably deserves some kind of answer.If I understand, you are basically asking for the difference between the different AndroidContextobjects. The main diff
阅读全文
摘要:(1)[ 01-01 08:39:22.016 1228:0x4cd E/AndroidRuntime ]java.lang.Exception: WakeLock finalized while still held: My Tagat android.os.PowerManager$WakeLock.finalize(PowerManager.java:337)at dalvik.system.NativeStart.run(Native Method)WakeLock finalized while still held 表示 WakeLock对象在销毁时仍然被持有。因为我的Activi
阅读全文
摘要:Android一个调试问题Log信息:[2010-10-25 17:31:43 - SQLite2] Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER[2010-10-25 17:31:43 - SQLite2] Please check logcat output for more details.[2010-10-25 17:31:44 - SQLite2] Launch canceled!原因:用户重复定义了Provider,产生了冲突。错误位置:在工程一的Androidmanifest中定义了 android:authori
阅读全文
摘要:这几天做项目,用到背景选择器,无论怎么弄,都没有效果,找了很多资料都没有找到,样式是这样的<?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/title_new_normal"/> <item android:drawable="@d
阅读全文
摘要:前几天因为项目的需要,要在一个ListView中放入另一个ListView,也即在一个ListView的每个ListItem中放入另外一个ListView。但刚开始的时候,会发现放入的小ListView会显示不完全,它的高度始终有问题。上网查了下,发现别人也有遇到这样的问题,而大多数人都不推荐这样的设计,因为默认情况下Android是禁止在ScrollView中放入另外的ScrollView的,它的高度是无法计算的。又搜索了一下,发现有StackOverflow上的牛人已经解决了这个问题,经过试验发现是可以解决问题的,它的思路就是在设置完ListView的Adapter后,根据ListView
阅读全文
摘要:In revision 17 of the Android SDK Tools and of the Eclipse ADT plug-in, we have made a lot of improvements to the dependency management of Android projects.The first thing we changed was to align both the Ant-based build system and the Eclipse plug-in so that they behave the same.Projects have sourc
阅读全文
摘要:在TabHost的子Activity中startActivityForResult调用其他Activity时候遭遇到onActivityResult方法不响应的问题.解决办法如下:1.通过父Activity启动其他Activity;2.实现父Activity的onActivityResult方法,将该处接收到的请求转发给当前活动的子Activity;3.自定义一个转发接口用来实现第2步中的转发功能;4.子Activity中实现第3步接口中的方法用来接收返回信息;代码如下:1.通过父Activity启动其他ActivitygetParent().startActivityForResult(ne
阅读全文
摘要:在主Activity中加入以下代码:@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { dialog(); return false; } return false; } protected void dialog() { AlertDial...
阅读全文
摘要:错误: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@435def20 is not valid; is your activity running? 发生环境: 在一个tabActivity里面嵌套一个tabAcitivity, 如果在子tabActivity里面显示AlertDialog的话,就会引发此错误。 解决方法: AlertDialog.Builder(xxx.this)
阅读全文
摘要:在ActivityGroup的sub activity中直接使用Spinner会遇到下面的异常信息:ERROR/AndroidRuntime(964): FATAL EXCEPTION: mainERROR/AndroidRuntime(964):android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@44f02d20 is not valid; is your activity runni..
阅读全文

浙公网安备 33010602011771号