You should remove the setContentView(tv1..tv2). You need to do setContentView only once with your XML ID. The text view will automatically display what you put using setText.
R/ On Fri, May 1, 2009 at 9:03 AM, [email protected] <[email protected]> wrote: > > Hi > I will create twi TextView in the main layout, but only last > TextView can be showed. > > My codes: > > package myapp.helloworld; > > import android.app.Activity; > import android.os.Bundle; > import android.widget.TextView; > import android.graphics.Color; > > public class helloworld extends Activity { > /** Called when the activity is first created. */ > �...@override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > TextView tv1 = new TextView(this); > tv1.setText("This is sample."); > tv1.setTextColor(Color.RED); > setContentView(tv1); > > TextView tv2 = new TextView(this); > tv2.setText("This is yellow."); > tv2.setTextColor(Color.YELLOW); > setContentView(tv2); > } > } > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

