導航:首頁 > 操作系統 > android修改edittext

android修改edittext

發布時間:2022-09-23 17:08:39

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,這個屬性是用來控制游標顏色的
android:textCursorDrawable="@null","@null"作用是讓游標顏色和text
color一樣

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,有問題的話就追加吧

閱讀全文

與android修改edittext相關的資料

熱點內容
ai文件pdf 瀏覽:909
騰訊雲伺服器掛載混合雲 瀏覽:758
智能小車用什麼單片機 瀏覽:463
java怎麼給窗口關閉 瀏覽:940
列舉51單片機的定址方式 瀏覽:706
剪輯app怎麼寫長篇文字 瀏覽:400
app專屬流量過月租怎麼不更新 瀏覽:654
王者程序員都有誰 瀏覽:76
給牛換腳掌解壓 瀏覽:387
圍棋有多少種演算法 瀏覽:602
unity資源包在哪個文件夾 瀏覽:704
阿里雲伺服器遠程鏈接不成功 瀏覽:482
文件系統pdf 瀏覽:766
原神安卓區服什麼意思 瀏覽:37
貝殼app怎麼線上發布 瀏覽:159
如何挑選安卓系統機頂盒 瀏覽:54
安卓快充使用有什麼注意事項 瀏覽:909
黑馬程序員的雲計算網課 瀏覽:947
endnotestyle文件夾怎麼導入 瀏覽:460
講解少兒編程演講會開頭 瀏覽:426