APIDEMO阅读小结

 

1、从TextView 返回的Editabel 可以是先append功能
Editable text = (Editable)mResults.getText();
text.append("(okay ");

TextView 另一强大功能setError(CharSequence error) 可以设置PopUp提示,用来说明输入为空,或者错误
重载方法setError(CharSequence error, Drawable icon);其中icon为文本框内的图标

2、可以将Activity 的属性设置为Theme.Dialog显示任意 view
详情可以查看CustomDialogActivity

android:theme="@style/Theme.CustomDialog"

<style name="Theme.CustomDialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/filled_box</item>
</style>

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f0600000"/>
<stroke android:width="3dp" color="#ffff8080"/>
<corners android:radius="3dp" />
<padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" />
</shape>


3、壁纸管理WallpaperManager
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();//获取当前的壁纸
wallpaperDrawable.setColorFilter(mColors[mColor], PorterDuff.Mode.MULTIPLY);//过滤色

4、半透明activity
android:theme="@style/Theme.Translucent // 设置透明主题

5、半透明activity +背景模糊
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
android:theme="@style/Theme.Translucent // 设置透明主题

6、壁纸为背景
android:theme="@style/Theme.Wallpaper" //

7、之前Dialog无法用返回键取消是因为返回键被屏蔽了

8、通过setType 获取文件
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("audio/*");
startActivity(Intent.createChooser(intent, "Select music"));

 

10、从xml中inflater menu
MenuInflater inflater = getMenuInflater();
inflater.inflate(menuId, menu);

11、ConditionVariable 包含 堵塞的方法

12、修改Toast中的View的方法  devoloper 中的 Notificition Toast 有介绍 修改 Toast 位置 视图的介绍
protected void showToast()
{
// create the view
View view = inflateView(R.layout.incoming_message_panel);

// set the text in the view
TextView tv = (TextView) view.findViewById(R.id.message);
tv.setText("khtx. meet u for dinner. cul8r");

// show the toast
Toast toast = new Toast(this);
toast.setView(view);
toast.setDuration(Toast.LENGTH_LONG);
toast.show();
}

private View inflateView(int resource)
{
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return vi.inflate(resource, null);
}

}

14、继承PreferenceActivity 通过载入addPreferencesFromResource(R.xml.default_values)可以显示视图
用来配置设置比较方便


15、postDelayed(Runnable r, long delayMillis) 将一个Runnable加入线程队列,在一定时间后执行


16、TextView link 的用法
1、 使用android:autoLink="all" 属性
2、 在String 用html格式配置URL Tel
3、在代码中设置String 并且调用t3.setMovementMethod(LinkMovementMethod.getInstance());方法
4、SpannableString ss = new SpannableString("text4: Click here to dial the phone.");
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, 6, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new URLSpan("tel:4155551212"), 13, 17, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

t4.setText(ss);
t4.setMovementMethod(LinkMovementMethod.getInstance());

CharacterStyle 抽象类的各种子类可以实现一段TextView文本中的 部分文本的替换
如:URLSpan可以替换URL , StyleSpan可以替换样式 , ForegroundColorSpan 可以替换文本颜色


17、 listview 加载item时的动画 :详情参见 apiDemo--》LayoutAnimation2
LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);//set 为animation
ListView listView = getListView();
listView.setLayoutAnimation(controller);

或者使用android:layoutAnimation="@anim/layout_grid_fade"属性配置
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="0.5"
android:animationOrder="random"
android:animation="@anim/fade" />


18 、Chronometer精密计算器,用来计时

posted @ 2012-08-25 16:49  lipeil  阅读(582)  评论(0编辑  收藏  举报