Question

Android Studio (Java) Develop an android app that contains two fragments displayed on one activity. The...

Android Studio (Java)

Develop an android app that contains two fragments displayed on one activity.

The bottom fragment contains / displays several rows of individual buttons and each of these buttons resemble a letter of the alphabet such as the first button "A" second button "B" etc.. all the way to Z as well as buttons for the numbers 0 - 9.

Once a user clicks a button, the corresponding letter or number button they pressed should display in the top fragment.

For example: If a user presses Button "H" then presses button "E" then "L" then "L" and then "O" in the bottom fragment, then the text "HELLO" should be displayed in the top fragment. In other words the app works like a notepad

Please provide screenshots of the output OF THE WORKING APP and please include the FULL CODE OF EVERY FILE / MODIFIED FILES used in the creation of this application for example.

MainActivity.java

// code here

activity_main.xml

// code here

If you have any questions please be specific.

Thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the answer..

CODE:

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="vertical" tools:context=".MainActivity"> <TextView android:layout_width="match_parent" android:layout_height="100dp" android:textSize="20dp" android:hint="enter" android:id="@+id/text_view" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:onClick="submit" android:layout_weight="0.1" android:id="@+id/one" android:text="1"/> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:id="@+id/two" android:text="2" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:id="@+id/three" android:text="3" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:id="@+id/four" android:text="4" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="5" android:id="@+id/five"/> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:id="@+id/six" android:text="6" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:id="@+id/seven" android:text="7" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:id="@+id/eight" android:text="8" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:id="@+id/nine" android:text="9" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:id="@+id/zero" android:text="0" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:id="@+id/q" android:text="q" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="w" android:id="@+id/w"/> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="e" android:id="@+id/e"/> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="r" android:id="@+id/r"/> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="t" android:id="@+id/t"/> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="y" android:id="@+id/y"/> <Button android:id="@+id/u" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="u" /> <Button android:id="@+id/i" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="i" /> <Button android:id="@+id/o" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="o" /> <Button android:id="@+id/p" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="p" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/a" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="a" /> <Button android:id="@+id/s" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="s" /> <Button android:id="@+id/d" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="d" /> <Button android:id="@+id/f" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="f" /> <Button android:id="@+id/g" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="g" /> <Button android:id="@+id/h" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="h" /> <Button android:id="@+id/j" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="j" /> <Button android:id="@+id/k" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="k" /> <Button android:id="@+id/l" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="l" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/z" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="z" /> <Button android:id="@+id/x" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="x" /> <Button android:id="@+id/c" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="c" /> <Button android:id="@+id/v" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="v" /> <Button android:id="@+id/b" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="b" /> <Button android:id="@+id/n" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="n" /> <Button android:id="@+id/m" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="m" /> <Button android:id="@+id/clr" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.1" android:onClick="submit" android:text="cl" /> </LinearLayout> </LinearLayout>

MainActivity.java

package com.example.buttons; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity { TextView textView; String str=""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView=findViewById(R.id.text_view); } public void submit(View view) { //here getting the id of corresponding Button id's Button btn=findViewById(view.getId()); //checking whether it is clr id or not if(R.id.clr == view.getId()) { //clears the string when it is not empty in the textview if(!str.equals("")) { str = str.substring(0, str.length() - 1); textView.setText(str); } } else { //here adding the clicked buttons to the string String st=btn.getText().toString(); // concatinating the clicked button text to the string str = str+st; //setting the text in the textview textView.setText(str); } } }

OUTPUT:

I have added clear button extra

If you have any doubts please COMMENT...

If you understand the answer please give THUMBS UP.....

Add a comment
Know the answer?
Add Answer to:
Android Studio (Java) Develop an android app that contains two fragments displayed on one activity. The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Project 03 (Chapter 04 Multiple Activities) Code an app in android studio that does the following:...

    Project 03 (Chapter 04 Multiple Activities) Code an app in android studio that does the following: There is one button in the middle of the screen. The button color is green and its text says 0. When the user clicks on the button GO, we go to a second activity that is red and has one button in the middle of the screen; its text says BACK. When the user clicks on that button, we go back to the first...

  • If anyone here is a Java and Android Studio expert please I really need help fulfilling...

    If anyone here is a Java and Android Studio expert please I really need help fulfilling the requirements needed to make a Rock Paper Scissors game. I mainly need Java code to complete it I will post what I have so far I don't have much time left please if anyone can help me I would really appreciate it. Here's what the app is supposed to do... The player should be able to select either Rock, Paper, or Scissors.The app...

  • Please code the following Java App using Swing No additional classes are required. With that in...

    Please code the following Java App using Swing No additional classes are required. With that in mind ... Write a program that emulates a calculator. Create a Label with a title of "Super Calculator", a textbox, where the numbers are displayed, a series of buttons labeled as shown, and a “Clear” button. As the user enters the numbers, pressing the number buttons, display the numbers right justified to the textbox. When the user press any one of the operators, +,...

  • • Create an Android Stop Watch mobile application based on the below requirements: ◦ The Stop Watch App will display the...

    • Create an Android Stop Watch mobile application based on the below requirements: ◦ The Stop Watch App will display the time as: ▪ HH:MM:SS.mmmm Where HH represents the number of hours; MM represents the number of minutes; SS represents the number of seconds; mmmm represents the number of milliseconds. For example, ▪ 02:09:57.1234 The above time example would read: ▪ Two hours and ▪ Nine minutes and ▪ Fifty seconds and ▪ One thousands two hundreds thirty four milliseconds...

  • Tip Calculator App For this project, you will create a tip calculator Android app. The user...

    Tip Calculator App For this project, you will create a tip calculator Android app. The user should enter their bill amount into an EditText and then select the desired tip percentage using a SeekBar. When the user moves the SeekBar’s dial, the tip amount and total amount are displayed in separate TextViews below. Your Tip Calculator App should very closely resemble the one shown here: Widgets • At the top of the app, include a TextView that contains your name...

  • Exercise 11-4 Create a Reminder app In this exercise, you’ll add a service to a Reminder...

    Exercise 11-4 Create a Reminder app In this exercise, you’ll add a service to a Reminder app that displays a notification every hour that says, “Look into the distance. It’s good for your eyes.” Test the app 1. Start Android Studio and open the project named ch11_ex4_Reminder. 2. Review the code. Note that it contains a layout and a class for an activity, but no class for a service. 1. Run the app. Note that it displays a message that...

  • In Java, please write the program for the following program. Please TEST YOUR PROGRAM. You MUST...

    In Java, please write the program for the following program. Please TEST YOUR PROGRAM. You MUST use GUI, that means all user input must be through the windows. The "first window" is the window on the top left of the following picture. Add 5 more items to be purchased. Search is accessed from second window, top right. Thw third window is the bottom left, and the fourth window is the bottom right. The program MUST CONTAIN EVERYTHING IN THE PICTURES....

  • This assignment is about creating the Rolodex application that contains the contact information. Each contact information...

    This assignment is about creating the Rolodex application that contains the contact information. Each contact information includes: First name Last name Middle name (optional) Phone number The Rolodex application will use SharedPreferences for data persistent operations: Retrieve Rolodex records Add a new Rolodex record Update the existing Rolodex record Delete the selected Rolodex record The Rolodex application uses Fragment and DialogFragment. In addition, the Rolodex records are displayed in the ListView view. The ListView view is set to be single-selection...

  • This is python3. Please help me out. Develop the following GUI interface to allow the user...

    This is python3. Please help me out. Develop the following GUI interface to allow the user to specify the number of rows and number of columns of cards to be shown to the user. Show default values 2 and 2 for number of rows and number of columns. The buttons "New Game" and "Turn Over" span two column-cells each. Fig 1. The GUI when the program first starts. When the user clicks the "New Game" button, the program will read...

  • Java: In this assignment, you will create an accumulator accumulator-calculator that displays a sad face “...

    Java: In this assignment, you will create an accumulator accumulator-calculator that displays a sad face “ :-( “ whenever the number displayed by the calculator is negative and a happy face “ :-) ” whenever the number displayed is positive. The calculator responds to the following commands: num + , num - , num * , num / and C ( Clear ). After initial run, if the user clicks 8 and then presses the “+” button for example, the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT