Do this Intent myIntent = new Intent(androidGallery.this, helloAndroid.class); startActivity(myIntent);
On Mon, Dec 14, 2009 at 3:56 AM, Lynn Ooi <lynnooi....@gmail.com> wrote: > hi, > > I had 2 activity (called androidGallery and HelloAndroid). i try to > call helloAndroid from the androidGallery when user click on the > button. basically, androidGallery is just to get the onclick event. > The helloAndroid activity will set the text of a textview. however, i > cant get it working. Once i click the button, a dialog box pop up > saying that the application has been stopped unexpectedly with a force > close button. Can anyone help me with it? > > androidGallery.java : > > package testt.android.androidgallery; > > import android.app.Activity; > import android.content.Intent; > import android.os.Bundle; > import android.view.View; > import android.widget.Button; > > public class androidGallery extends Activity { > private Button btnclickme; > > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > final Button button = (Button) findViewById(R.id.button_id); > button.setOnClickListener(new View.OnClickListener() { > public void onClick(View v) { > // Perform action on click > Intent myIntent = new Intent(androidGallery.this, > helloAndroid.class); > androidGallery.this.startActivity(myIntent); > } > }); > > } > } > > helloAndroid.java : > > package test.android.androidgallery; > > import java.io.BufferedInputStream; > import java.io.InputStream; > import java.net.URL; > import java.net.URLConnection; > import java.util.ArrayList; > import java.util.List; > > import org.apache.http.util.ByteArrayBuffer; > > import android.app.Activity; > import android.os.Bundle; > import android.util.Log; > import android.widget.TextView; > > public class helloAndroid extends Activity{ > /** Called when the activity is first created. */ > public void onCreate(Bundle savedInstanceState) { > // super.onCreate(savedInstanceState); > // setContentView(R.layout.main); > String a = "hello Lynn"; > super.onCreate(savedInstanceState); > TextView tv = new TextView(this); > tv.setText(a); > setContentView(tv); > } > } > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > To post to this group, send email to android-beginners@googlegroups.com > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en