Android点滴(四)
来源:互联网 发布:淘宝天天特价报名 编辑:程序博客网 时间:2024/06/10 15:15
如何为Activity屏幕的标题栏添加图标?
要注意的是,win.setFeatureDrawableResource必须在setContentView之后,不然就没有效果。
如何让ListView自动滚动?
注意stackFromBottom以及transcriptMode这两个属性。类似Market客户端的低端不断滚动。
<ListView android:id="listCWJ"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
/>
如何设置桌面壁纸?
希望在你的程序中能设置桌面壁纸吗?很简单,首先我们需要取得设置壁纸的权限。和其它权限一样,只要在配置文件中加上以下配置信息即可。
<uses-permission android:name="android.permission.SET_WALLPAPER" />
然后在程序中调用如下代码即可设置桌面壁纸:
getApplicationContext().setWallpaper(bitmap)
如何在标题栏(titlebar)显示进度条?
如何去掉activity顶部的gradient?
<style name="Theme.Foo" parent="android:style/Theme.Light">
<item name="android:windowContentOverlay">@null</item>
</style>
<activity android:name=".FooActivity"
android:theme="@style/Theme.Foo"> ...
http://wang-peng1.iteye.com/blog/680015
如何让ScrollView强制滑到底部?
scroll.fullScroll(View.FOCUS_DOWN) 就可以了
如何ViewFlipper去掉多余空间?
ViewFlipper flipper = (ViewFlipper)findViewById(R.id.flipper);
flipper.setMeasureAllChildren(false);
如何去掉tabhost横线?
如何判断国家?
如何让屏幕保持一直亮?
http://wang-peng1.iteye.com/blog/769561
如何检查sim卡状态?
如何从SMS获取联系人信息?
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- Window win = getWindow();
- win.requestFeature(Window.FEATURE_LEFT_ICON);
- setContentView(R.layout.mylayout);
- win.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon);
- }
如何让ListView自动滚动?
注意stackFromBottom以及transcriptMode这两个属性。类似Market客户端的低端不断滚动。
<ListView android:id="listCWJ"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
/>
如何设置桌面壁纸?
希望在你的程序中能设置桌面壁纸吗?很简单,首先我们需要取得设置壁纸的权限。和其它权限一样,只要在配置文件中加上以下配置信息即可。
<uses-permission android:name="android.permission.SET_WALLPAPER" />
然后在程序中调用如下代码即可设置桌面壁纸:
getApplicationContext().setWallpaper(bitmap)
如何在标题栏(titlebar)显示进度条?
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);//先给Activity注册界面进度条功能
- setContentView(R.layout.main);
- setProgressBarIndeterminateVisibility(true);//在需要显示进度条的时候调用这个方法
- setProgressBarIndeterminateVisibility(false);//在不需要显示进度条的时候调用这个方法
- }
如何去掉activity顶部的gradient?
<style name="Theme.Foo" parent="android:style/Theme.Light">
<item name="android:windowContentOverlay">@null</item>
</style>
<activity android:name=".FooActivity"
android:theme="@style/Theme.Foo"> ...
http://wang-peng1.iteye.com/blog/680015
如何让ScrollView强制滑到底部?
scroll.fullScroll(View.FOCUS_DOWN) 就可以了
如何ViewFlipper去掉多余空间?
ViewFlipper flipper = (ViewFlipper)findViewById(R.id.flipper);
flipper.setMeasureAllChildren(false);
如何去掉tabhost横线?
- 很简单 简单的有时候是因为我们太浮躁
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:gravity="center_horizontal">
- <TabHost
- android:id="@android:id/tabhost"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- ...
- ...
- ...
- </TabHost>
- </LinearLayout>
- 外面加一层LinearLayout
如何判断国家?
- String locale = context.getResources().getConfiguration().locale.getCountry();
- String locale = context.getResources().getConfiguration().locale.getDisplayCountry();
- TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
- String countryCode = tm.getSimCountryIso();
- @Override
- protected void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
http://wang-peng1.iteye.com/blog/769561
如何检查sim卡状态?
- TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- int simState = telMgr.getSimState();
- switch (simState) {
- case TelephonyManager.SIM_STATE_ABSENT:
- // do something
- break;
- case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
- // do something
- break;
- case TelephonyManager.SIM_STATE_PIN_REQUIRED:
- // do something
- break;
- case TelephonyManager.SIM_STATE_PUK_REQUIRED:
- // do something
- break;
- case TelephonyManager.SIM_STATE_READY:
- // do something
- break;
- case TelephonyManager.SIM_STATE_UNKNOWN:
- // do something
- break;
- }
如何从SMS获取联系人信息?
- ContactItem getContactByAddr(Context context, final SMSItem sms) {
- Uri personUri = Uri.withAppendedPath(
- ContactsContract.PhoneLookup.CONTENT_FILTER_URI, sms.mAddress);
- Cursor cur = context.getContentResolver().query(personUri,
- new String[] { PhoneLookup.DISPLAY_NAME },
- null, null, null );
- if( cur.moveToFirst() ) {
- int nameIdx = cur.getColumnIndex(PhoneLookup.DISPLAY_NAME);
- ContactItem item = new ContactItem();
- item.mName = cur.getString(nameIdx);
- cur.close();
- return item;
- }
- return null;
- }
- Android点滴(四)
- 学习点滴(四)
- 生活、工作点滴(四)
- Android点滴(一)
- Android点滴(二)
- Android点滴(三)
- Android点滴(五)
- Android点滴(一)
- Django点滴(四)---ORM对象存取
- QT学习点滴记录(四)
- redis点滴(四) redis持久化
- Android 学习点滴(1)
- Android 学习点滴(2)
- Android 学习点滴(3)
- Android点滴
- android 点滴
- android 点滴
- Android点滴
- 中文繁体字与简体字转换
- js ==与===区别(两个等号与三个等号)
- sizeof运算符和size_t类型
- Linux性能监控小结
- levelDB源码分析-提纲
- Android点滴(四)
- Android开发之ClipboardManager
- FckEditor for java 2.4 JSP配置详解
- windows下提升进程权限 LUID
- 2
- Log4Net
- uva 10161 - Ant on a Chessboard
- 3
- 业务流程建模标注(BPMN)详细介绍