android 小常识

能够在EditText前面放置一个看不到的LinearLayout,让它率先获取焦点:
<LinearLayout
        android:focusable="true"  android:focusableInTouchMode="true"
        android:layout_width="0px"  android:layout_height="0px"/>
自定义全屏控件
  LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
        		LinearLayout.LayoutParams.FILL_PARENT,
        		LinearLayout.LayoutParams.WRAP_CONTENT
        );
android 设置textview中划线效果
textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );
底部加横线是
textview.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );
//获取当前设置的电话号码
    public String getNativePhoneNumber() {
        String NativePhoneNumber=null;
        NativePhoneNumber=telephonyManager.getLine1Number();
        return NativePhoneNumber;
    }
//listview 和 button 共存
在item上添加 android:descendantFocusability="blocksDescendants" 或者 button 添加android:focusable="false"
//背景透明
View v = findViewById(R.id.content);//找到你要设透明背景的layout 的id
v.getBackground().setAlpha(100);//0~255透明度值
//获得webview 选中的文字
获取选中的内容要调用webView中的未公开函数getSelection 所以经过反射:
Method m = WebView.class.getMethod("getSelection", null);
m.setAccessible(true);
Object obj = m.invoke(webview, null);
obj.toString()就是选中的内容
listview操做
android:cacheColorHint="#00000000" 滑动取消黑色
android:listSelector="@null"  取消点击效果
 android:divider="@null" 不要中间的线

想隐藏软键盘或者填完内容后点其余的地方直接隐藏软键盘 android

InputMethodManager manager = (InputMethodManager) getSystemService(SetZTGJCDetailsActivity.INPUT_METHOD_SERVICE);
 @Override
 public boolean onTouchEvent(MotionEvent event) {
  if (event.getAction() == MotionEvent.ACTION_DOWN) {
   if (getCurrentFocus() != null && getCurrentFocus().getWindowToken() != null) {
    manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
   }
  }
  return super.onTouchEvent(event);
 }

webview 打开视频、pdf。

http://www.youtube.com/watch?v=....mp4
http://docs.google.com/gview?embedded=true&url=....pdf


 @Override
        public void setUserVisibleHint(boolean isVisibleToUser) {
                // TODO Auto-generated method stub
                if (isVisibleToUser) {
                        //fragment可见时加载数据
        } else {
            //不可见时不执行操做
        }
                super.setUserVisibleHint(isVisibleToUser);
        }

int[] location = new int[2];
// 获取当前view在屏幕中的绝对位置
// ,location[0]表示view的x坐标值,location[1]表示view的坐标值
view.getLocationOnScreen(location);
相关文章
相关标签/搜索