Android(Java):Android中常用的代碼

 
1代碼中設置margin
RelativeLayout.LayoutParams margin = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
margin.setMargins(30, 8, 0, 0); 
viewHolder.tvName.setLayoutParams(margin);
 
2圓弧的效果
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="@color/areaschildrenselected"/>
    <corners android:radius="8dip" />
</shape> 
 
3onkeydown
@Override
 public boolean dispatchKeyEvent(KeyEvent event) {
  // TODO Auto-generated method stub
  CommonUtils.log(TAG, "onKeyDown");
  if(KeyEvent.ACTION_DOWN==event.getAction()){
   return DoubleBack.doubleBackHanlder(this,event.getKeyCode());
  }
  return false;
 }
 
4得到資源中的asset數據流
InputStream in = getResources().getAssets().open("ehcache.xml");//得到資源中的asset數據流
 
5
if(progressDialog==null){
  progressDialog = new ProgressDialog(mContext);
 }
 progressDialog.setMessage("視頻正在加載中,請稍後");
 progressDialog.show();
 
if (progressDialog == null) {
   progressDialog = ProgressDialog.show(this, null, getString(R.string.loginwait), true);
  }
  progressDialog.show();
發佈了51 篇原創文章 · 獲贊 2 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章