FILE MainClass.java
package xxx.yyy;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MainClass extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.items);
// This
Test1();
// or that
Class2 c2 = new Class2();
C2.Test2();
}
public void Test1() {
setContentView(R.layout.layoutA);
TextView tv = (TextView)findViewById(R.id.DisplayLine);
tv.setText("Start");
}
}
-----------------------------------------------------------------------
FILE Class2.java
package xxx.yyy;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Class2 extends Activity {
TextView tv;
// @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public void Test2 () {
setContentView(R.layout.layoutA);
TextView tv = (TextView)findViewById(R.id.DisplayLine);
tv.setText("Start");
}
}
---------------------------------------------------------------
FILE layoutA.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:id="@+id/DisplayLine"
android:layout_width="350px"
android:layout_height="40px"
android:background="#ff99ff99"
android:textStyle="bold"
android:textColor="#ff000000"
android:layout_x="10px"
android:layout_y="10px"
>
</TextView>
</AbsoluteLayout>
If Test1 is allowed to run, it is OK.
If Test2 is allowed to run, get FORCE CLOSE.
--
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