Loading app/src/main/java/com/example/game2d/NameActivity.java +39 −0 Original line number Diff line number Diff line Loading @@ -8,8 +8,13 @@ import android.content.SharedPreferences; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.PopupWindow; import android.widget.RelativeLayout; import android.widget.TextView; import android.os.Handler; Loading @@ -26,11 +31,19 @@ public class NameActivity extends AppCompatActivity implements View.OnClickListe int currentQuestionIndex = 0; String selectedAnswer = ""; //for pop up intro RelativeLayout layout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_name); //for pop up intro layout = findViewById(R.id.nameActivity); // relative is the id of the layout of the page CreatepopUpwindow(); totalQuestionsTextView = findViewById(R.id.total_question); nameTextView = findViewById(R.id.names); yes = findViewById(R.id.yes); Loading @@ -50,6 +63,32 @@ public class NameActivity extends AppCompatActivity implements View.OnClickListe loadNewQuestion(); } //for pop up window private void CreatepopUpwindow() { LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View popUpView=inflater.inflate(R.layout.mainpopup,null); int width = ViewGroup.LayoutParams.MATCH_PARENT; int height= ViewGroup.LayoutParams.MATCH_PARENT; boolean focusable = true; PopupWindow popupWindow = new PopupWindow(popUpView, width,height,focusable); layout.post(new Runnable() { @Override public void run() { popupWindow.showAtLocation(layout, Gravity.BOTTOM,0,0); } }); TextView Continue; Continue = popUpView.findViewById(R.id.Continue); Continue.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { popupWindow.dismiss(); } }); } @Override public void onClick(View view) { Loading app/src/main/java/com/example/game2d/mainpopup.java 0 → 100644 +5 −0 Original line number Diff line number Diff line package com.example.game2d; public class mainpopup { } app/src/main/res/drawable/buttonbg.xml 0 → 100644 +6 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="50dp"/> <solid android:color="@color/black" /> </shape> No newline at end of file app/src/main/res/drawable/popupbg.xml 0 → 100644 +5 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/white" /> <corners android:radius="30dp" /> </shape> No newline at end of file app/src/main/res/layout/activity_name.xml +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ android:layout_height="match_parent" android:background="@color/white_200" android:padding="24dp" android:id="@+id/nameActivity" tools:context=".MainActivity"> Loading Loading
app/src/main/java/com/example/game2d/NameActivity.java +39 −0 Original line number Diff line number Diff line Loading @@ -8,8 +8,13 @@ import android.content.SharedPreferences; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.PopupWindow; import android.widget.RelativeLayout; import android.widget.TextView; import android.os.Handler; Loading @@ -26,11 +31,19 @@ public class NameActivity extends AppCompatActivity implements View.OnClickListe int currentQuestionIndex = 0; String selectedAnswer = ""; //for pop up intro RelativeLayout layout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_name); //for pop up intro layout = findViewById(R.id.nameActivity); // relative is the id of the layout of the page CreatepopUpwindow(); totalQuestionsTextView = findViewById(R.id.total_question); nameTextView = findViewById(R.id.names); yes = findViewById(R.id.yes); Loading @@ -50,6 +63,32 @@ public class NameActivity extends AppCompatActivity implements View.OnClickListe loadNewQuestion(); } //for pop up window private void CreatepopUpwindow() { LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View popUpView=inflater.inflate(R.layout.mainpopup,null); int width = ViewGroup.LayoutParams.MATCH_PARENT; int height= ViewGroup.LayoutParams.MATCH_PARENT; boolean focusable = true; PopupWindow popupWindow = new PopupWindow(popUpView, width,height,focusable); layout.post(new Runnable() { @Override public void run() { popupWindow.showAtLocation(layout, Gravity.BOTTOM,0,0); } }); TextView Continue; Continue = popUpView.findViewById(R.id.Continue); Continue.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { popupWindow.dismiss(); } }); } @Override public void onClick(View view) { Loading
app/src/main/java/com/example/game2d/mainpopup.java 0 → 100644 +5 −0 Original line number Diff line number Diff line package com.example.game2d; public class mainpopup { }
app/src/main/res/drawable/buttonbg.xml 0 → 100644 +6 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="50dp"/> <solid android:color="@color/black" /> </shape> No newline at end of file
app/src/main/res/drawable/popupbg.xml 0 → 100644 +5 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/white" /> <corners android:radius="30dp" /> </shape> No newline at end of file
app/src/main/res/layout/activity_name.xml +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ android:layout_height="match_parent" android:background="@color/white_200" android:padding="24dp" android:id="@+id/nameActivity" tools:context=".MainActivity"> Loading