android UI控件

1,關於text和drawableTop之類的間距html

android:drawablePadding="10dp"

java代碼裏設置自定義的字體顏色java

counetdownView.setTextColor(mContext.getColorStateList(R.color.text_pre_white_to_gary));

listViewandroid

2,商城分類瀏覽ide

列表單選效果佈局

去掉分割線字體

設置list模式(含多個)code

默認選中第一個htm

3,edittext屬性blog

Android:phoneNumber=」true」  //輸入電話號
android:maxLength=「50」 字數限制
Android:editable // 是否可編輯
代碼中清除焦點-不會改變編輯狀態
edittext.clearFocus();
在EditText中軟鍵盤的調起、關閉
android:focusable="false"//禁止獲取焦點
在父佈局設置如下兩個屬性,取消默認獲取焦點
android:focusable="true" 
android:focusableInTouchMode="true" 
android:cursorVisible="false" 隱藏光標
android:background="#00000000"//不要文本框背景 
android:numeric來控制輸入的數字類型,一共有三種分別爲integer(正整數)、signed(帶符號整數,有正負)和decimal(浮點數)。
軟鍵盤的調起致使原來的界面被擠上去,或者致使界面下面的tab導航被擠上去,解決方法以下
解決方法:
使用Manifest中的Activity的android:windowSoftInputMode的"adjustPan"屬性。
另外注意:有關軟鍵盤的問題可參考android:windowSoftInputMode中屬性。

(1)EditText有焦點(focusable爲true)阻止輸入法彈出
 editText=(EditText)findViewById(R.id.txtBody);
   editText.setOnTouchListener(new OnTouchListener(){  
         public boolean onTouch(View v, MotionEvent event){ 
            editText.setInputType(InputType.TYPE_NULL); //關閉軟鍵盤     
            return false;
         }
    });
當EidtText無焦點(focusable=false)時阻止輸入法彈出
 InputMethodManager imm =
(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); 
 imm.hideSoftInputFromWindow(editText.getWindowToken(),0);
//關閉鍵盤(好比輸入結束後執行) InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(etEditText.getWindowToken(), 0);
 
//自動彈出鍵盤
((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);
etEditText.requestFocus();//讓EditText得到焦點,可是得到焦點並不會自動彈出鍵盤

,4,用於RecyclerView的adapter刷新數據,只有把新的數據傳到adapter裏而後notifyDataSetChanged()就能夠了,若是數據不少,固然也有針對單條的數據更改事件

public void refresh(List<Variety> list) {
        mVarietyList = list;
        notifyDataSetChanged();//刷新所有數據
        //notifyItemInserted(1); 新添加一條
        //notifyItemRemoved(1);刪除一條
    }

五、ImageView圖片位置

http://www.cnblogs.com/pandapan/p/4614837.html

6.若是滑動裏嵌套列表,事件衝突 ,若是列表只是用於顯示,最簡單的就是把列表控件的事件取消

mRecyclerView.setNestedScrollingEnabled(false);

7.SearchView使用,搜索後由展開到關閉(縮小)

searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                //query:輸入框內容
                //設置兩次setIconified是爲了讓searchView收縮
                searchView.setIconified(true);//設置一次是清空內容
                searchView.setIconified(true);//縮小
                return false;
            }
            @Override
            public boolean onQueryTextChange(String newText) {
                return false;
            }
        });
相關文章
相關標籤/搜索