Question

In: Computer Science

Android Studio Code: Provide a working android studio code i.e java and xml code for the...

Android Studio Code:

Provide a working android studio code i.e java and xml code for the activity below:

Develop an application that is capable to turn pages back and forth.

Detailed Instructions:

For the main activity, create a layout that represents a fictitious title and author. The activity should include a clickable button on the bottom right that allows you to go forward to the next activity. The next activity will simply be an image above simple text that can say anything.

Once in the next activity, below the text there should be two clickable buttons. On the left, a button that will take us back to our original title page. The right button does not need to go anywhere.

Solutions

Expert Solution

Java Code

Adding a new activity to the project
Next, we need to create the activity ( the screen ) where the button will take us.
Menu -> File -> New -> Activity -> Empty Activity.
Another method
App -> Java -> right click on packagename.projectname -> New -> Activity -> Empty Activity

package com.example.intentbasic;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void Moveto(View view) {
Intent i = new Intent(MainActivity.this, Main2Activity.class);
MainActivity.this.startActivity(i);
}
}

//Second activity
package com.example.intentbasic;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class SecondActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}

public void BackHome(View view){
Intent i2 = new Intent(SecondActivity.this, MainActivity.class);
SecondActivity.this.startActivity(i2);
}

}

//xml code

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.intentbasic.FirstActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Author Name"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="179dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent" />


<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="189dp"
android:layout_marginLeft="18dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="18dp"
app:layout_constraintRight_toRightOf="parent" />
  
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="35dp"
android:onClick="Moveto"
android:text=">>"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
</android.support.constraint.ConstraintLayout>

//xml code of second activity

<?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=".SecondActivity"
android:id="@+id/myLayout">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="<<"
android:onClick="BackHome"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=">>"
android:onClick="Movefwd"/>
<ImageView
   android:id="@+id/image"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="#000000"
   android:gravity="center"
   android:padding="32dp"
   android:contentDescription="@string/imgDesc"
   android:src="@drawable/image1"/>
</LinearLayout>


Related Solutions

the code base you will be working with involves an Android application. (Android Studio) application name...
the code base you will be working with involves an Android application. (Android Studio) application name " SharingApp" In the application’s current state: A user of the app is able to create and edit a profile with a unique username and an email address. A user of the app is able to login and logout. An owner is able to record the items they own and wish to share. A bidder is able to place bids on items they wish...
Android Studio. Java. Please create an application that -> An activity that allows user to enter...
Android Studio. Java. Please create an application that -> An activity that allows user to enter name, gender, date of birth, state of residence (selected from a pre-defined list: CA, AZ, NV, OR), email address and favorite website. This activity has a button "Show Data" that displays detail entered
Hi! I need it in android studio and in java Design a game app “BouncingBall ”...
Hi! I need it in android studio and in java Design a game app “BouncingBall ” in which the user’s goal is to prevent a bouncing ball from falling off the bottom of the screen. When the user presses the start button, a ball bounces off the top, left and right sides (the “walls”) of the screen. A horizontal bar on the bottom of the screen serves as a paddle to prevent the ball from hitting the bottom of the...
Hi! I need it in android studio and in java Design a game app “BouncingBall ”...
Hi! I need it in android studio and in java Design a game app “BouncingBall ” in which the user’s goal is to prevent a bouncing ball from falling off the bottom of the screen. When the user presses the start button, a ball bounces off the top, left and right sides (the “walls”) of the screen. A horizontal bar on the bottom of the screen serves as a paddle to prevent the ball from hitting the bottom of the...
android studio Begin a new app and create a Java class for products with data: productName,...
android studio Begin a new app and create a Java class for products with data: productName, productCode and price and use a file of objects to store product data and read back and display on screen. Do this by creating a simple form using EditTexts, buttons or ActionBar items and display output using an Alert.
Create a Scorekeeper app in android studio by using java language - Layouts | Widgets Create...
Create a Scorekeeper app in android studio by using java language - Layouts | Widgets Create the layout for your score keeping app. The app should have: Two team names (TextViews) Two scores (TextViews) Buttons to increase/ decrease the scores An amount to change the score by (RadioButtons) You must have at least two score options The scores can be changed by anything you want American football: 1, 2, 3, 6 Basketball: 1, 2, 3 Freestyle wrestling: 1, 2, 3,...
android studio -Starting with a basic activity, create a new Java class (use File->New->Java class) called...
android studio -Starting with a basic activity, create a new Java class (use File->New->Java class) called DataBaseManager as in Lecture 5 and create a database table in SQLite, called StudentInfo. The fields for the StudentInfo table include StudentID, FirstName, LastName, YearOfBirth and Gender. Include functions for adding a row to the table and for retrieving all rows, similar to that shown in lecture 5. No user interface is required for this question, t -Continuing from , follow the example in...
I am doing a 4 function calculator app in java on android studio which calculates math...
I am doing a 4 function calculator app in java on android studio which calculates math expressions (add, subtract, multiply, and divide). I ONLY NEED THE CODE THE EQUAL BUTTON. When the user clicks the equal button, it should take the entire sequence of numbers and operators on the screen, such as 1+2*5 , and save them into a String [I am pretty sure this can be done using the toString() call]. Then, the String should be split using StringTokenizer,...
I need the JAVA code for a 4 function calculator app on andriod studio - The...
I need the JAVA code for a 4 function calculator app on andriod studio - The requirements are the following : - The only buttons needed are 0-9, *, /, +, -, a clear, and enter button - Implement the onclicklistener on the main activity - The calcuator should use order of operations (PEMDAS) - It should be able to continue from a previous answer (Ex: If you type 2+6 the calculator will display 8. If you then multiple by...
XML and XSL I'm trying to style my XML code but it's not implementing the XSL...
XML and XSL I'm trying to style my XML code but it's not implementing the XSL file when I run it even though the file is referenced. Any help? XML code: <?xml version="1.0"?> <?xml-stylesheet href="textbooks.xsl" type="text/xsl" ?> <textbooks> <textbook> <title> Introduction to Design and Analysis of Algorithms</title> <authors> <author> <firstName>Anany</firstName> <lastName>Levitin</lastName> </author> </authors> <publisher> <name>Ed, Pearson</name> <website>https://www.pearson.com</website> </publisher> <Year-of-Publication>2011</Year-of-Publication> <ISBN>978-0132316811</ISBN> <book-specific-website></book-specific-website> <edition>3rd edition</edition> <cover-type>Paperback</cover-type> </textbook> <textbook> <title>Software Engineering: A Practitioner’s Approach</title> <authors> <author> <firstName>Roger</firstName> <lastName>Pressman</lastName> </author> </authors> <publisher> <name>Ed, McGraw-Hill</name>...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT