Android Tutorial TabHost tutorial

Status
Not open for further replies.

leitor79

Active Member
Licensed User
Longtime User
Hi!

I have a scheme where I have 2 activities, Activity1 and Activity2, each one with his own layout (layActivity1.bal and layActivity2.bal) which I load at Activity_Create on each activity.

I want to use one activity with a tabhost containing 2 tabs, each one with the content of each activity.

So, It would be correct to create an "Activity3" with a tabhost, load the two layouts each one on a tab and "join" the code from Activity2 and Activity2 in Activity3?

Thank you very much!
 

leitor79

Active Member
Licensed User
Longtime User
Hi Erel, thank you for your answer.

I know about activities and layouts, I just wasn't clear enough (or I'm missing something else).

The thing with my activities and layouts is that the code I ask to "merge" uses the views defined on the layouts. For example, I have a customlistview in layout1 which I populate in Activity1. Same with layout2 and Activity2.

Should I put both customlistview's objects into the activity3 (the one with the tabhost) and add the code to populate it from each activity into activity3?

What code do you suggest I could put into a class? (I'm and old VB programmer so I use classes when I need objects)

Regards!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Should I put both customlistview's objects into the activity3 (the one with the tabhost) and add the code to populate it from each activity into activity3?
Yes. This is one option.

The second option is to create a class for each layout with its views and then handle the views events in the class code.
 

leitor79

Active Member
Licensed User
Longtime User
Yes. This is one option.

The second option is to create a class for each layout with its views and then handle the views events in the class code.

Hi Erel, Thank you for your answer.

And how the view's event would be fired when using the activity? How do I relate the activity with that class? Or is that automatic?

Regards,
 

leitor79

Active Member
Licensed User
Longtime User
I don't really understand.
Why not just use one activity with the TabHost and the two layouts ?
Why having the two other activities with wach layout once ?

Hi Klaus, thank you for your answer.

That's because my current project has 2 activities with one layout each, and I'm trying to switch to a tabhost model with less changes possible.

Regards,
 

Ganiadi

Active Member
Licensed User
Longtime User
Hi, Im newbie and need help
I Try to use the tab host and action bar, but when i try to click Home Button that should handle the pulldown menu it throw error.
Pls anybody may help...i also enclosed the source for evaluate

Tq in advance
 

Attachments

  • ActionBar demo.zip
    488.4 KB · Views: 527

Javier Campo Martinez

Member
Licensed User
Hi guys !!!
With this Manifest, the code doesn't show the icon(s)

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

Just added android:targetSdkVersion="26"

Is there any workaround or fix for this ?

Thanks in advance, and best regards.
 

Javier Campo Martinez

Member
Licensed User

The answer --> https://www.b4x.com/android/forum/threads/tabhost-i-cant-see-icons.29420/
It works for me ... !!!!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…