-
May152012
在向google code提交项目时出现了以下问题:
123Commit failed(details follow):
Server sent unexpected return value (405 Method Not Allowed) in response to
MKACTIVITY request for '/svn/!svn/act/b75d925f-f4dc-ad46-9dfc-d0b8c865dcb8'
问题原因:
原来是svn地址错误,使用https,而不是http
阅读全文
-
May152012
在Android系统中进行JSON解析时碰到以下问题:
1org.json.JSONException: Value  of type java.lang.String cannot be converted to JSONObject
使用Notepad++设置文件编码时,采用utf8编码,出现上面的问题。原因是文件中包含了utf8 bom头信息。采用utf8无BOM格式编码的形式即可。
具体设置,查看下图:
阅读全文
-
May152012
前面贴过Android系统内部的MediaFile类来获取文件类型的办法,这个类主要是根据文件的扩展名来判断,其准确性不是很好。具体可查看Android系统使用MediaFile类判断音频文件类型。其实,获取文件类型最好的办法便是根据文件头信息来判断。下面贴出相关代码:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566...阅读全文
-
Apr292012
Android系统中TextView实现跑马灯效果,必须具备以下几个条件:
1、android:ellipsize=”marquee”
2、TextView必须单行显示,即内容必须超出TextView大小
3、TextView要获得焦点才能滚动
XML代码:
1android:ellipsize="marquee", android:singleLine="true"
Java代码:
123mTVText.setText("哼唱接撒砥砺风节雷锋精神http://orgcent.com/,很长很长很长很长很...阅读全文
-
Apr292012
Android系统默认给TextView插入图片提供了三种方式:
1、ImageSpan
2、Html.ImageGetter
3、TextView.setCompoundDrawables(left, top, right, bottom)
1、TextView使用ImageSpan显示图片
1234ImageSpan span = new ImageSpan(this, R.drawable.ic_launcher);
SpannableString spanStr = new SpannableString("http://orgcent.com");
spanStr.setSpan(span,...阅读全文
-
Apr292012
TextView设置文字透明效果,只要降低文字颜色的透明度就可以了。而让文本高亮显示可以设置文本的背景或前景色高亮。
1、TextView设置文字透明效果
123//android:textColor="#ff00ff00"
//在XML中使用颜色码设置文本颜色,若要设置透明度,只须设置第一、二位数字即可。颜色码的规则:透明度(2位)红色(2位)绿色(2位)蓝色(2位)
mTVText.setTextColor(Color.argb(35, 0, 25...阅读全文
-
Apr292012
EditText继承于TextView类,是Android系统中的文本输入框。系统使用Selection类来对EditText的内容进行选择指定文本、全选等操作,同时可以设置光标显示位置和显示出指定位置的文本。
1、EditText选择部分文本和全选
12345678EditText etSelection = (EditText) findViewById(R.id.etSelection);
etSelection.setText("测试绚丽斯蒂芬森就连手机发送旅客附近&quo...阅读全文
-
Apr292012
TextView设置文本字体有XML和Java代码两种方式。XML代码通常只能设置系统默认提供的几种字体如normal,sans,serif, monospace,Java代码则可以设置自定义第三方字体如宋体等。
1、XML代码方式
1<TextView android:typeface=" sans" />
2、Java代码方式
123mTVText.setText("自定义字体");
final Typeface tf = Typeface.createFromAsset(getAssets...阅读全文
-
Apr292012
Android系统显示HTML网页的最佳控件为WebView,有时候为了满足特定需求,需要在TextView中显示HTML网页、图片及解析自定义标签。
1、TextView显示Html类解析的网页
1234CharSequence richText = Html.fromHtml("<strong>萝卜白菜的博客</strong>--<a href='http://orgcent.com'>http://orgcent.com</a>");
mTVText.setText(richText);
/...阅读全文
-
Apr282012
TextView要让文本垂直/水平居中显示,有两种情况需要考虑:
1、layout_width/layout_height为wrap_content,此时要让TextView在父控件上居中显示,必须设置layout_gravity=”center”。
2、layout_width/layout_height为fill_parent,此时由于TextView已占据父窗体所有空间,必须设置gravity=”center”。
PS:android:gravity用来设置TextView的内容对齐方式,android:layout_gravity用来设置Te...阅读全文