Ⅰ android editText如何在代碼中設置可以編輯
http://blog.csdn.net/luliyuan/article/details/8065447
1、首先想到在xml中設置android:editable="false",但是如果想在代碼中動態設置可編輯狀態,沒有找到對應的函數
2、然後嘗試使用editText.setFocusable(false);和editText.setEnabled(false);設置不可編輯狀態;editText.setFocusable(true);和 editText.setEnabled(true);設置可編輯狀態。
發現在editText.setFocusable(false);和editText.setEnabled(false);時不可編輯,但是editText.setFocusable(true);和 editText.setEnabled(true);也是不可編輯的,感覺這個時候EditText控制項高亮度了,但是沒有焦點
3、最後嘗試使用editText.setFocusable(false);和editText.setFocusableInTouchMode(false);設置不可編輯狀態;editText.setFocusableInTouchMode(true);editText.setFocusable(true);editText.requestFocus();設置可編輯狀態
這個可以實現可編輯和不可編輯
Ⅱ android怎麼改變Edittext樣式我想在不改變
方法如下:
1.去掉邊框
EditText的background屬性設置為@null就搞定了:android:background="@null"
style屬性倒是可加可不加。
2.改變邊框顏色
代碼如下:
[html] view plain
<EditText
android:layout_width="fill_parent"
android:layout_height="36dip"
android:background="@drawable/bg_edittext"
android:padding="5dip"
android:layout_margin="36dip"
android:textColorHint="#AAAAAA"
android:textSize="15dip"
android:singleLine="true"
android:hint="請輸入..."
/>
Ⅲ android中如何更改EditText 的游標顏色
EditText有一個屬性:android:textCursorDrawable,這個屬性是用來控制游標顏色的1 在代碼中進行設置更改默認提示的字體大小
SpannableString hintStr = new SpannableString(getResources().getString(R.string.search_tittle));// 定義hint的值
AbsoluteSizeSpan ass = new AbsoluteSizeSpan(14, true);// 設置字體大小 true表示單位是SP
hintStr.setSpan(ass, 0, hintStr.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
search_et.setHint(new SpannedString(hintStr));
2 在布局文件中進行設置EditText更改游標的的寬度和顏色
android:textCursorDrawable="@drawable/shape_et_cursor"
shape資源是
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:width="2dp" />
<solid android:color="#FF5899" />
</shape>
3 EditText常用屬性
android:textCursorDrawable="@null" 控制游標顏色 "@null"不設置顏色和editText的顏色一致 設置顏色要使用
@drawable/shape 屬性
editText.setSelection(2) 使游標移動到制定的位置
editText.requestFocus() 請求出現游標時獲取焦點
editText.clearFocus() 清除游標,失去焦點
editText.setCursorVisible(false) 不出現游標
android:imeOptions="actionSearch" 彈出鍵盤出現搜索按鈕
android:inputType="text" 輸入字元串
Ⅳ android 怎麼改變Edittext樣式
你可以重寫 Edittext 不過這個比較麻煩,簡單的實現。製作兩種背景圖片(普通和獲得焦點兩種樣式),寫一個drawbale的xml 。然後設為EditText的背景就ok了
Ⅳ android 怎麼給edittext設置一個值
edittext.setText(「要設置的內容」);
Ⅵ 新手求助android在JAVA代碼中修改EditText的相關屬性。
應該是在button的setOnClickListener方法裡面傳值new一個View.onClickListener,onClickListener的onClick事件裡面寫上 editText.setFocusable(true)
具體一個字母可能不同,我沒有開eclipse,有問題的話就追加吧