activity_main.xml 拡張子:txtvbswsfjsphpjavahtmlutf8sjis <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:padding="16dp"> <ViewSwitcher android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/viewSwitcher"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <include android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/buttons" android:id="@+id/include1"/> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/scrollView" android:layout_alignParentStart="true" android:layout_below="@+id/include2"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="150dp" android:id="@+id/textView1"/> <TextView android:layout_width="match_parent" android:layout_height="150dp" android:id="@+id/textView2"/> <TextView android:layout_width="match_parent" android:layout_height="150dp" android:id="@+id/textView3"/> <TextView android:layout_width="match_parent" android:layout_height="150dp" android:id="@+id/textView4"/> </LinearLayout> </ScrollView> </LinearLayout> <include android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/entry"/> </ViewSwitcher> </LinearLayout> buttons.xml 拡張子:txtvbswsfjsphpjavahtmlutf8sjis <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button1" android:id="@+id/button1" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button2" android:id="@+id/button2" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button3" android:id="@+id/button3" android:layout_weight="1"/> </LinearLayout> entry.xml 拡張子:txtvbswsfjsphpjavahtmlutf8sjis <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <include android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/buttons" android:id="@+id/include2"/> <EditText android:layout_width="match_parent" android:layout_height="match_parent" android:inputType="textMultiLine" android:id="@+id/editText" android:textSize="20dp"/> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:padding="16dp"> <ViewSwitcher android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/viewSwitcher"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <include android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/buttons" android:id="@+id/include1"/> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/scrollView" android:layout_alignParentStart="true" android:layout_below="@+id/include2"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="150dp" android:id="@+id/textView1"/> <TextView android:layout_width="match_parent" android:layout_height="150dp" android:id="@+id/textView2"/> <TextView android:layout_width="match_parent" android:layout_height="150dp" android:id="@+id/textView3"/> <TextView android:layout_width="match_parent" android:layout_height="150dp" android:id="@+id/textView4"/> </LinearLayout> </ScrollView> </LinearLayout> <include android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/entry"/> </ViewSwitcher> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button1" android:id="@+id/button1" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button2" android:id="@+id/button2" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button3" android:id="@+id/button3" android:layout_weight="1"/> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <include android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/buttons" android:id="@+id/include2"/> <EditText android:layout_width="match_parent" android:layout_height="match_parent" android:inputType="textMultiLine" android:id="@+id/editText" android:textSize="20dp"/> </LinearLayout>
拡張子:txtvbswsfjsphpjavahtmlutf8sjis public class MainActivity extends AppCompatActivity { private ViewSwitcher vs; // ***************************************** // 初期画面構築 // ***************************************** @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); vs = (ViewSwitcher) MainActivity.this.findViewById(R.id.viewSwitcher); vs.setInAnimation(AnimationUtils.loadAnimation( MainActivity.this, android.R.anim.fade_in)); vs.setOutAnimation(AnimationUtils.loadAnimation( MainActivity.this, android.R.anim.fade_out)); Action1 action1 = new Action1(MainActivity.this); action1.initAction(); Action2 action2 = new Action2(MainActivity.this); action2.initAction(); } }
public class MainActivity extends AppCompatActivity { private ViewSwitcher vs; // ***************************************** // 初期画面構築 // ***************************************** @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); vs = (ViewSwitcher) MainActivity.this.findViewById(R.id.viewSwitcher); vs.setInAnimation(AnimationUtils.loadAnimation( MainActivity.this, android.R.anim.fade_in)); vs.setOutAnimation(AnimationUtils.loadAnimation( MainActivity.this, android.R.anim.fade_out)); Action1 action1 = new Action1(MainActivity.this); action1.initAction(); Action2 action2 = new Action2(MainActivity.this); action2.initAction(); } }
拡張子:txtvbswsfjsphpjavahtmlutf8sjis public class Action1 { private MainActivity context; private ViewSwitcher vs; public Action1(MainActivity context) { this.context = context; } public void initAction(){ vs = (ViewSwitcher) context.findViewById(R.id.viewSwitcher); View include1 = context.findViewById(R.id.include1); // ***************************************** // ボタン1 の設定 // ***************************************** Button btn1 = (Button)include1.findViewById(R.id.button1); btn1.setText("次画面"); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action1:btn1"); vs.setDisplayedChild(1); } }); // ***************************************** // ボタン2 の設定 // インターネットのデータを次画面に引き渡す // ***************************************** Button btn2 = (Button)include1.findViewById(R.id.button2); btn2.setText("処理2"); btn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action1:btn2"); } }); // ***************************************** // ボタン3 の設定 // ブラウザ呼び出し // ***************************************** Button btn3 = (Button)include1.findViewById(R.id.button3); btn3.setText("処理3"); btn3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action1:btn3"); } }); } } 拡張子:txtvbswsfjsphpjavahtmlutf8sjis public class Action2 { private MainActivity context; private ViewSwitcher vs; public Action2(MainActivity context) { this.context = context; } public void initAction(){ vs = (ViewSwitcher) context.findViewById(R.id.viewSwitcher); View include2 = context.findViewById(R.id.include2); // ***************************************** // ボタン1 の設定 // ***************************************** Button btn1 = (Button)include2.findViewById(R.id.button1); btn1.setText("戻る"); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action2:btn1"); vs.setDisplayedChild(0); } }); // ***************************************** // ボタン2 の設定 // インターネットのデータを次画面に引き渡す // ***************************************** Button btn2 = (Button)include2.findViewById(R.id.button2); btn2.setText("処理B"); btn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action2:btn2"); } }); // ***************************************** // ボタン3 の設定 // ブラウザ呼び出し // ***************************************** Button btn3 = (Button)include2.findViewById(R.id.button3); btn3.setText("処理C"); btn3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action2:btn3"); } }); } }
public class Action1 { private MainActivity context; private ViewSwitcher vs; public Action1(MainActivity context) { this.context = context; } public void initAction(){ vs = (ViewSwitcher) context.findViewById(R.id.viewSwitcher); View include1 = context.findViewById(R.id.include1); // ***************************************** // ボタン1 の設定 // ***************************************** Button btn1 = (Button)include1.findViewById(R.id.button1); btn1.setText("次画面"); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action1:btn1"); vs.setDisplayedChild(1); } }); // ***************************************** // ボタン2 の設定 // インターネットのデータを次画面に引き渡す // ***************************************** Button btn2 = (Button)include1.findViewById(R.id.button2); btn2.setText("処理2"); btn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action1:btn2"); } }); // ***************************************** // ボタン3 の設定 // ブラウザ呼び出し // ***************************************** Button btn3 = (Button)include1.findViewById(R.id.button3); btn3.setText("処理3"); btn3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action1:btn3"); } }); } }
public class Action2 { private MainActivity context; private ViewSwitcher vs; public Action2(MainActivity context) { this.context = context; } public void initAction(){ vs = (ViewSwitcher) context.findViewById(R.id.viewSwitcher); View include2 = context.findViewById(R.id.include2); // ***************************************** // ボタン1 の設定 // ***************************************** Button btn1 = (Button)include2.findViewById(R.id.button1); btn1.setText("戻る"); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action2:btn1"); vs.setDisplayedChild(0); } }); // ***************************************** // ボタン2 の設定 // インターネットのデータを次画面に引き渡す // ***************************************** Button btn2 = (Button)include2.findViewById(R.id.button2); btn2.setText("処理B"); btn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action2:btn2"); } }); // ***************************************** // ボタン3 の設定 // ブラウザ呼び出し // ***************************************** Button btn3 = (Button)include2.findViewById(R.id.button3); btn3.setText("処理C"); btn3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("lightbox", "Action2:btn3"); } }); } }