Textview + MapView on Tabs

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Textview + MapView on Tabs

Postby nr1 » Mon Dec 28, 2009 10:42 pm

Hi,

i have a TabWidget that should contain 3 Tabs.
Each of this Tabs should contain a TextView at the Top and a MapView that uses the remaining space.

I need to set the text of the TextView and Overlays on the MapView individually for each tab.

How can i do that?

I already found the following tutorial:
http://vkroz.wordpress.com/2009/07/03/p ... -tab-view/
but i don't know how to modify it to fit the specifications above.

thx!
nr1
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue Aug 11, 2009 6:27 pm

Top

Postby achie1266 » Tue Dec 29, 2009 1:07 am

Is the problem with having the text at the top or the overlay.
if its etting thext at the top then you just add text view at the top and add layout_weight="1.0" for the MapView
I have seen tutorials but have not done overlay myself personally.

I will try to help you if i can though if you can give some more detail about your problem/ or which part you are not able to accomplish.
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby nr1 » Tue Dec 29, 2009 8:20 am

I already added a Textview in the Mapactivity.
I can also display this textview + mapview combination as tabs.

But i don't know how to access the textview and mapview directly at runtime (for example if i want to change the textview text or if i want to do some mapview action on a certain tab)
nr1
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue Aug 11, 2009 6:27 pm

Postby achie1266 » Tue Dec 29, 2009 9:14 am

hey nr1,

you can access any of the views from the current layout in this way
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. TextView tv = (TextView)findViewById(R.id.text1);
  2.  
  3. tv.setText("any text you want");
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

the same can be done with the mapviews also. You have to look at the java docs for the corresponding documentation of TextView and MapView and use the functions that are available on those classes.

If you need more detailed explanation like a tutorial, you need to search for topics which explain how to change the layout from java code.

Coming to the second part of your question, if you want to pass these views to the tabView then you may have to use make them static and then access them from the tabActivity in a static way.
If you need help with any part of your code, then posting that snippet will help others to understand it clearly and modify it if it is a quick fix.

gl
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby nr1 » Tue Dec 29, 2009 5:43 pm

I attached the full code example:

Each Tab contains a textview + mapview.
How can i set the text of the textview in runtime?
Attachments
TabMapsExample.zip
Example
(43.1 KiB) Downloaded 79 times
nr1
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue Aug 11, 2009 6:27 pm

Postby achie1266 » Tue Dec 29, 2009 5:54 pm

I am at work right now, and I cant work on it right away, so please bear with me.
But hopefully someone else might take a look at this.
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Top

Postby achie1266 » Tue Dec 29, 2009 6:13 pm

in your maptabview you have the textview and webview like this
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.                     <TextView xmlns:android="http://schemas.android.com/apk/res/android"
  2.  
  3.                           android:layout_width="fill_parent"
  4.  
  5.                           android:layout_height="50px"
  6.  
  7.                           android:id="@+id/textview"/>
  8.  
  9.                    
  10.  
  11.                     <com.google.android.maps.MapView android:id="@+id/mapview"
  12.  
  13.                        android:layout_width="fill_parent" android:layout_height="fill_parent"
  14.  
  15.                        android:clickable="true"
  16.  
  17.                        android:apiKey=""/>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
You need the ids from those views to call them in the java code.
in your MapTabView you can access them after you call setContentView on R.layout.maptabview.

after setContentView you need to create textview objects and point them to these views. you then will be able to change the properties on them.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. TextView tv = (TextView)findViewById(R.id.textview));//this is the same as the id in your layout.
  2.  
  3. tv.setText("Your Custom text");
  4.  
  5. //also set any other properties like background or color etc..[docs]
  6.  
  7. MapView wv = (MapView)findViewById(R.id.mapview));
  8.  
  9. //you can now set the properties on the wv object [docs]
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
You might want to look at the notepad example and follow the steps given there and finish that tutorial so that you will have a basic idea of how to do all these things. It really helped me a lot to get me started.

If you donot want to do the whole tutorial you can also go through the examples that google provided in the sdk.
they will be located in your sdk at a location similar to this.
sdk/android-sdk-linux/platforms/android-2.0/samples/ApiDemos.
there you can look at the src and look at the corresponding layouts in res/layout

hope this helps you.
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby nr1 » Tue Dec 29, 2009 6:36 pm

Hi :D

i know all the stuff you posted, but i don't know how to do it in the example, as i just have some intents that i'm sending to the tabwidget as tabcontent.
nr1
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue Aug 11, 2009 6:27 pm

Postby achie1266 » Tue Dec 29, 2009 6:45 pm

well sorry but in your last post you said that you want to set the text of your textview.
Each Tab contains a textview + mapview.
How can i set the text of the textview in runtime?

I am not sure if i understand what you want here.
i don't know how to do it in the example, as i just have some intents that i'm sending to the tabwidget as tabcontent.
can you explain what you are trying to do :roll:
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby nr1 » Wed Jan 06, 2010 1:03 pm

Just show me how i can set the zoom level of the mapview intent for example.

thx
nr1
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue Aug 11, 2009 6:27 pm

Postby nr1 » Thu Jan 07, 2010 11:23 am

no one?
nr1
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue Aug 11, 2009 6:27 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests