Hi All,
I have a project with many tabhosts and many edittexts within these.
When I switch tabs I get a focus on the first tab. This brings up the keyboard.
This is a pain when most of the time all I want to do is view.
How can I make it that nothing has the focus until I select it.
I have dimmed an editfocus as EditText, Initiaiized it then on any tab change
I call a editFocus.RequestFocus
But this does not work. My thoughts were that this edittect would take the focus. Oh well just a :sign0104:
I've tried to reproduce it with this code and the keyboard doesn't popup unless I click on the EditText:
B4X:
Sub Globals
Dim th As TabHost
End Sub
Sub Activity_Create (FirstTime As Boolean)
th.Initialize("th")
Dim p1, p2 As Panel
p1.Initialize("")
p2.Initialize("")
Dim b1 As Button
b1.Initialize("")
p1.AddView(b1, 10dip, 10dip, 100dip, 100dip)
Dim et As EditText
et.Initialize("")
p2.AddView(et, 10dip, 10dip, 100dip, 100dip)
th.AddTab2("1", p1)
th.AddTab2("2", p2)
Activity.AddView(th, 0, 0, 100%x, 100%y)
End Sub
Just tested your code.
with the xoom on tab 2 the edittext does get the focus and the keyboard comes up. Maybe it is the xoom. If this is the case can I put code in that takes the fosus away from the edittext?
You can try setting the focus to an EditText with InputType = INPUT_TYPE_NONE.
You may need to use a short timer for it to work. Enable the timer when the tab changes, set the focus from the timer and disable the timer.
Hi Erel,
I setup a non visible edittext.
set the tomer for 10 millseconds then put in this
B4X:
Sub TabHost1_TabChanged
Dim i As Int
Timer1.Enabled= True
i = TabHost1.CurrentTab
Activity.Title= "tab no = "& i & " blocks= " & blocks.Length
If Built AND (blocks.Length>i) Then
edtTab.Text = blocks(i)
' ToastMessageShow(blocks(i),True)
End If
End Sub
Sub Timer1_Tick
edtF.RequestFocus
Timer1.Enabled=False
End Sub