当前位置: 编程技术>移动开发
本页文章导读:
▪从http中取得 Inputstream 从http中获得 Inputstream
/**
* 从http中获得 Inputstream
*
* @param url http地址
* @return inputstream
* @throws java.io.IOException IOException
*/
private static InputStream getInputStreamFromHttp(String ur.........
▪ 4.0源码编译有关问题 4.0源码编译问题
1、fatal error: GL/glx.h: No such file or directorydevelopment/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22: fatal error: GL/glx.h: No such file or directory compilation terminated.make: *** [out/hos.........
▪ 怎么实现TextView的Marquee效果 如何实现TextView的Marquee效果
往往看到一些应用的标题栏中当标题超出时便会自动滚动
这篇文章要讲的就是如何去实现TextView的Marquee效果
其实TextView已经自带了如何实现滚动的属性
android:.........
[1]从http中取得 Inputstream
来源: 互联网 发布时间: 2014-02-18
从http中获得 Inputstream
/**
* 从http中获得 Inputstream
*
* @param url http地址
* @return inputstream
* @throws java.io.IOException IOException
*/
private static InputStream getInputStreamFromHttp(String url) throws IOException {
URL downUrl = new URL(/blog_article/url/index.html);
HttpURLConnection connection = (HttpURLConnection)downUrl.openConnection();
connection.connect();
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
return connection.getInputStream();
}
return null;
}
[2] 4.0源码编译有关问题
来源: 互联网 发布时间: 2014-02-18
4.0源码编译问题
1、fatal error: GL/glx.h: No such file or directory
development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22: fatal error: GL/glx.h: No such file or directory compilation terminated.
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon_intermediates/GLDispatch.o] Error 1
解决方法:sudo apt-get install libgl1-mesa-dev
2、用mm编译apk时,会在out目录下生成.apk和.odex两个文件,这应该是为了加快运行速度,把dex分出来做的预处理。但是一般开发时需要mm编译出一个完整的apk,直接用adb进行安装就可以进行调试。在./build/core下有个package.mk文件,里面有一个选项,LOCAL_DEX_PREOPT ,4.0默认把这个选项设置成了true,将LOCAL_DEX_PREOPT值改为false,完整的apk就有了。
3、编译hdpi
android4.0的源码编译时lunch选择full-eng默认编译mdpi的apk,如果要编译hdpi,需要在./build/target/product/full.mk文件中添加:
PRODUCT_AAPT_CONFIG := normal hdpi
PRODUCT_AAPT_PREF_CONFIG := hdpi
4、 push apk 到模拟器
a).获得模拟器写权限
启动模拟器时添加参数 -partition-size
emulator -avd avdname -partition-size 256
./adb remount
b).把模拟器中/system/app下
要push的apk对应的odex文件删除
1、fatal error: GL/glx.h: No such file or directory
development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22: fatal error: GL/glx.h: No such file or directory compilation terminated.
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon_intermediates/GLDispatch.o] Error 1
解决方法:sudo apt-get install libgl1-mesa-dev
2、用mm编译apk时,会在out目录下生成.apk和.odex两个文件,这应该是为了加快运行速度,把dex分出来做的预处理。但是一般开发时需要mm编译出一个完整的apk,直接用adb进行安装就可以进行调试。在./build/core下有个package.mk文件,里面有一个选项,LOCAL_DEX_PREOPT ,4.0默认把这个选项设置成了true,将LOCAL_DEX_PREOPT值改为false,完整的apk就有了。
3、编译hdpi
android4.0的源码编译时lunch选择full-eng默认编译mdpi的apk,如果要编译hdpi,需要在./build/target/product/full.mk文件中添加:
PRODUCT_AAPT_CONFIG := normal hdpi
PRODUCT_AAPT_PREF_CONFIG := hdpi
4、 push apk 到模拟器
a).获得模拟器写权限
启动模拟器时添加参数 -partition-size
emulator -avd avdname -partition-size 256
./adb remount
b).把模拟器中/system/app下
要push的apk对应的odex文件删除
[3] 怎么实现TextView的Marquee效果
来源: 互联网 发布时间: 2014-02-18
如何实现TextView的Marquee效果
往往看到一些应用的标题栏中当标题超出时便会自动滚动
这篇文章要讲的就是如何去实现TextView的Marquee效果
其实TextView已经自带了如何实现滚动的属性
android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever"
通过上面的属性设置就能让TextView滚动起来。当然也可以通过代码去设置。
但是当设置完之后发现并没有滚动起来,原来TextView滚动的前提是这个空间必须要获得焦点。TextView需要必须处于focus状态。
在TextView的父类View中有一个方法isFocused(),系统通过这个方法去判断一个空间是否获得焦点。
所以我们就有了:
写一个子类继承TextView,重写isFocused()方法,直接返回true。当通过这个函数去判断TextView有没有获得焦点时,总是返回获得焦点于是我们的TextView就开始滚动起来了。代码很简单:
public class AlwaysMarqueeTextView extends TextView {
/**
* constructor
* @param context Context
*/
public AlwaysMarqueeTextView(Context context) {
super(context);
}
/**
* constructor
* @param context Context
* @param attrs AttributeSet
*/
public AlwaysMarqueeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* constructor
* @param context Context
* @param attrs AttributeSet
* @param defStyle int
*/
public AlwaysMarqueeTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean isFocused() {
return true;
}
}
最新技术文章: