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" 不要中间的线

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

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);

转载于:https://my.oschina.net/u/267190/blog/100590

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值