您的位置:首页 > 移动开发 > Android开发

android 技术细节整理

2011-08-29 16:59 253 查看
 

 1.dialog 添加视图时的 参数设置

        mProgressDialog.addContentView(tv,new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));

2.alertDialog  弹出对话框视图之外灰色的点击事件

      ad .getWindow().getDecorView().onTouchEvent(event)

 3..解决listview上 Item上有按钮时 item本身不能点击的问题:

      1. 在item试图上面添加代码: android:descendantFocusability="blocksDescendants"

      2.在listview里 添加代码 android:focusable="true"

4.float 按一定格式转换成string

    private String formatFloat(float f){

      return  new DecimalFormat("##.#").format(f);

    }

5.android返回键的屏蔽和处理

    

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

if(keyCode==KeyEvent.KEYCODE_BACK){
//添加自己的处理函数
return true;//返回true 则不在向上级传递,false则向上面传递
}
return super.onKeyDown(keyCode, event);
}


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息