basic question in intent

Put your problem here if it does not fit any of the other categories.

basic question in intent

Postby soniya » Tue Feb 12, 2008 4:08 pm

i make a simple class ..
in that class,make method ......
in method i use

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  Intent i1 = new Intent(this, Onitem.class);
  2.  
  3.                                        
  4.  
  5.                                     startSubActivity(i1,0);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


then it show error

Constructor Intent is undefined and method startSubActivity is undefined..
how to use intent???
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Top

Postby plusminus » Tue Feb 12, 2008 4:25 pm

Hello soniya,

you are probably within an anonymous class, like an OnClickListener or similar.
You need to use the this-Pointer of the surrounding Activity. like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. myButton.setOnItemClickListener(new OnItemClickListener(){
  2.  
  3.         @Override
  4.  
  5.         public void onItemClick(AdapterView arg0, View v, int arg2, long arg3) {
  6.  
  7.                 Intent myIntent = new Intent(OuterActivity.this, NewActivity.class);
  8.  
  9.                 OuterActivity.this.startActivity(myIntent....
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests