Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - How to get the context of current activity

How to get the context of current activity

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

How to get the context of current activity

Postby androidUser » Sun Apr 12, 2009 6:36 pm

Question:
- How to get the context of the current activty
- How to get a view from resource id


Requirement:
I am working with MapLocationOverlay to display the bubble.

In order to configure the MapLocationViewer in the tutorial2.xml

<com.pocketjourney.view.MapLocationViewer
android:id="@+id/map_location_viewer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>

any alternative solution. ?

//setContentView(R.layout.tutorial2); // Instead of calling the xml file
setContentView((View)new MapLocationViewer(????)); How to get the context ?
androidUser
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Apr 05, 2009 1:08 pm

Top

Postby padde » Sun Apr 12, 2009 8:12 pm

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class Test extends Activity {
  3.  
  4.  
  5.  
  6.     public void onCreate(Bundle icicle) {
  7.  
  8.         super.onCreate(icicle);
  9.  
  10.  
  11.  
  12.         Context myContext = this;     // this is how you get the context
  13.  
  14.  
  15.  
  16.         // and this is how you get the view via ID
  17.  
  18.         MapLocationViewer myViewer = (MapLocationViewer) findViewById(R.id.map_location_viewer);
  19.  
  20.  
  21.  
  22.         setContentView(myViewer);
  23.  
  24.     }
  25.  
  26.  
  27.  
  28. }
  29.  
  30.  
Parsed in 0.013 seconds, using GeSHi 1.0.8.4


I hope this is what you were looking for :)

Greets
Padde
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby androidUser » Tue Apr 14, 2009 10:34 am

padde wrote:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class Test extends Activity {
  2.  
  3.     public void onCreate(Bundle icicle) {
  4.         super.onCreate(icicle);
  5.  
  6.         Context myContext = this;     // this is how you get the context
  7.  
  8.         // and this is how you get the view via ID
  9.         MapLocationViewer myViewer = (MapLocationViewer) findViewById(R.id.map_location_viewer);
  10.  
  11.         setContentView(myViewer);
  12.     }
  13.  
  14. }
  15.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


I hope this is what you were looking for :)

Greets
Padde


In addition if i need to add the layout xml file(myfile.xml), how to add in setContentView() method ?
androidUser
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Apr 05, 2009 1:08 pm

Postby WarrenFaith » Tue Apr 14, 2009 10:47 am

Have you ever look once in a tutorial code?
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(R.layout.myfile);
Parsed in 0.010 seconds, using GeSHi 1.0.8.4

Every question are answered in the very first tutorial Hello World.
Please take a look at this website, read everything and than start asking....
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Postby androidUser » Tue Apr 14, 2009 10:49 am

WarrenFaith wrote:Have you ever look once in a tutorial code?
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(R.layout.myfile);
Parsed in 0.010 seconds, using GeSHi 1.0.8.4

Every question are answered in the very first tutorial Hello World.
Please take a look at this website, read everything and than start asking....


I agree. Please i am looking for different requirement,

Please note that in addition how to add the layout xml file in setContentView()?

Example: i am looking for somewhat setContentView(myViewer,R.layout.myfile);
androidUser
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Apr 05, 2009 1:08 pm

Postby WarrenFaith » Tue Apr 14, 2009 10:51 am

Please note that in addition how to add the layout xml file in setContentView()?

Example: i am looking for somewhat setContentView(myViewer,R.layout.myfile);

Afaik not possible. you have to set the content with R.layout.myfile and than you can add new Views.
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Top

Postby androidUser » Tue Apr 14, 2009 11:56 am

In order to send the value of myInput from an activity to MapLocationViewer

i removed the xml entry from the xml file.
<com.pocketjourney.view.MapLocationViewer
android:id="@+id/map_location_viewer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>

i have declared as setContentView((View)new MapLocationViewer(myContext,myInput));//So that i can get the myInput value in MapLocationViewer.

Now i am planning to have button in the screen(map). Note that i am using Overlay to display the bubble in map.

If we cannot use setContentView(myViewer,R.layout.myfile); then i have to work on Overlay to display the button.
androidUser
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Apr 05, 2009 1:08 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests