// All rights reserved Takatoshi Yanaase 2012 package patent.sample; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.EditText; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.Button; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.view.View.OnClickListener; // This program is for Android, but usual Java program can be written in the same manner. public class PatentActivity extends Activity { // @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); firstWindow(); } // private final void firstWindow(){ // root view TableLayout tableLayout = new TableLayout(this); tableLayout.setColumnStretchable(1, true); // text area TextView txtA = new TextView(this); txtA.setText("abcdef"); TableRow tableRow1 = new TableRow(this); tableLayout.addView(tableRow1); tableRow1.addView(txtA); // edit area EditText eTxt = new EditText(this); TableRow tableRow2 = new TableRow(this); tableLayout.addView(tableRow2); tableRow2.addView(eTxt); // butten to move to second window Button button = new Button(this); button.setText("switch"); TableRow tableRow3 = new TableRow(this); tableLayout.addView(tableRow3); tableLayout.addView(button); button.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View arg0, MotionEvent arg1) { // TODO Auto-generated method stub secondWindow(); return false; } }); // add views and draw this window setContentView(tableLayout); } // private final void secondWindow(){ // root view TableLayout tableLayout = new TableLayout(this); tableLayout.setColumnStretchable(1, true); // button to move to firsrt window Button button = new Button(this); button.setText("return"); button.setHeight(150); TableRow tableRow1 = new TableRow(this); tableLayout.addView(tableRow1); tableLayout.addView(button); button.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View arg0, MotionEvent arg1) { // TODO Auto-generated method stub firstWindow(); return false; } }); // edit area EditText eTxt = new EditText(this); eTxt.setHeight(200); TableRow tableRow2 = new TableRow(this); tableLayout.addView(tableRow2); tableRow2.addView(eTxt); // text view TextView txtA = new TextView(this); txtA.setText("ABCDEFGHIJK"); txtA.setHeight(300); TableRow tableRow3 = new TableRow(this); tableLayout.addView(tableRow3); tableRow3.addView(txtA); // add views and draw this window setContentView(tableLayout); } }