EditText ??

ilan

Expert
Licensed User
Longtime User
hi

i put a text into an edittext object
i would like to scroll down the text but whe i touch the edittext to scrolldown i get a menu that ask me if i want to selct all text..
and i can also edit the text

is it possibble to set the edit text like this that it is not edit able and no "select all menu" appears when i scroll down?
the text in the edit text should not be editable

thanx
 

lhbrito

Member
Licensed User
Longtime User
Hi Erel!! I'll resurrect this thread :)

I my application I want to put an activity with some EditView's, but depending on some conditions, the user can not edit the content. (to be read-only)

If left in "Enabled = False" works, but the color is bad for reading.

There is the case of using a LabelView in place of EditView, since in some cases the user can edit.

In this layout I have several fields, if they all always have the same behavior (editable or not), I can create two layouts: one with just LabelView and another with only EditView.

But if you just need some fields become editable already gets more complicated.

Have any other suggestions?
or
Can I change the appearance of EditView so it is disabled keep the same appearance when enabled?

Tks
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code to prevent the EditText from changing its looks:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   ChangeDisabledDrawable(EditText1)
End Sub

Sub ChangeDisabledDrawable(et As EditText)
   et.TextColor = et.TextColor 'removes the ColorStateList and sets a constant value
   Dim sd As StateListDrawable = et.Background
   Dim r As Reflector
   r.Target = sd
   Dim stateSet() As Int = Array As Int(sd.State_Enabled)
   Dim index As Int = r.RunMethod4("getStateDrawableIndex", Array As Object(stateSet), _
      Array As String("[I"))
   et.Background = r.RunMethod2("getStateDrawable", index, "java.lang.int")
End Sub
 
Upvote 0
Top