Question

In: Computer Science

This is an Android Question. I am trying to make a FAB(Floating Action Button) show me...

This is an Android Question. I am trying to make a FAB(Floating Action Button) show me a different page when I press it.

Solutions

Expert Solution

First, we add the floating action button to the layout in the xml file of the layout using the code below.

<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:src="@drawable/ic_my_icon"
        android:contentDescription="@string/submit"
        android:layout_margin="16dp" />

Next, in the Activity file, we need to define what happens when the floating action button is pressed.

FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {

        Intent intent = new Intent(this, SecondActivity.class);
        startActivity(intent);
    }
});

Here, we have added a listener to the floating action button set which would now start a new activity when the floating action button is pressed.   


Related Solutions

I am struggling with figureing this out as a practicing question! Please show me the work...
I am struggling with figureing this out as a practicing question! Please show me the work for how to get the correct answers! ABC Company produces two separate products, product A and product B.  Information on product A and B is reported below: Product A                                Product B Sales Price:                  $1,000                                     $1,800 Direct Materials          $100                                        $500 Direct Labor                $250                                        $600 Variable Overhead      $50                                          $400 Commissions:             $25                                          $40 Company information: Fixed Manufacturing overhead:          $400,000 per year Fixed Administrative Expenses:          $375,000 per year Tax rate:                                              25% ABC Company has to decide which of the following sales mixes will...
I am trying to create a PICO question research question. Can you please give me some...
I am trying to create a PICO question research question. Can you please give me some examples that i can use? At least 3 PICO questions and their research question and what do you want to find out about the issue. Thank you
BioChem Question I am trying to make a phosphate buffer, but I only have monoprotic potassium...
BioChem Question I am trying to make a phosphate buffer, but I only have monoprotic potassium phosphate. Should I expect the pH to be low or high once I dissolve the solid in water? Does this mean I should expect to need acid or base to adjust the pH to 7.0? Would formic acid or acetic acid be a better buffer at pH 5.0? Why? Which buffer would be my best choice if I need my reaction to be run...
I kept getting errors trying to make this code to work, can someone show me what...
I kept getting errors trying to make this code to work, can someone show me what i am doing wrong? import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.annotation.*; import java.io.*; import java.util.*; import java.nio.file.*; import java.nio.charset.*; import java.util.*; //@WebServlet(name = "Assignment3_1", urlPatterns = { "/ReadFile" }) public class ReadFile extends HttpServlet{ static Charset myCharset = Charset.forName("US-ASCII"); @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ response.setContentType("text/html"); PrintWriter printer = response.getWriter(); out.println("<html>"); out.println("<head>"); out.println("<title>"); out.println("Assignment 5.1"); out.println("</title>"); out.println("<h1>Is Bitcoin money?</h1>"); out.println("</head>"); out.println("<body>");...
I am trying to make a new code that uses functions to make it. My functions...
I am trying to make a new code that uses functions to make it. My functions are below the code. <?php */ $input; $TenBills = 1000; $FiveBills = 500; $OneBills = 100; $Quarters = 25; $Dimes = 10; $Nickels = 5; $Pennies = 1; $YourChange = 0; $input = readline("Hello, please enter your amount of cents:\n"); if(ctype_digit($input)) { $dollars =(int)($input/100); $cents = $input%100;    $input >= $TenBills; $YourChange = (int)($input/$TenBills); $input -= $TenBills * $YourChange; print "Change for $dollars dollars...
I am working on creating a Broadcast Receiver. I am extremely new to Android development and...
I am working on creating a Broadcast Receiver. I am extremely new to Android development and Java. I added my code at the bottom. Whenever I press the button the app crashes. I'm assuming something is wrong with connecting the broadcastIntent() function. I appreciate any help :) Here are the directions from my professor: Create an empty project Create a method in MainActivity.java which creates a Broadcast. public void broadcastIntent(View view){        Intent intent = new Intent();        intent.setAction("my.CUSTOM_INTENT"); sendBroadcast(intent);...
I am working on creating a Broadcast Receiver. I am extremely new to Android development and...
I am working on creating a Broadcast Receiver. I am extremely new to Android development and Java. I added my code at the bottom of this, but whenever I press the button the app crashes. I'm assuming something is wrong with connecting the broadcastIntent() function. If you could really focus on the first part that would be great!! I appreciate any help :) Here are the directions from my professor: Create an empty project Create a method in MainActivity.java which...
Assembly Question: I am trying to annotate this code and am struggling to understand what it...
Assembly Question: I am trying to annotate this code and am struggling to understand what it is doing. Can someone please add comments? .data .star: .string "*" .line: .string "\n" .input: .string "%d" .count: .space 8 .text .global main printstars: push %rsi push %rdi _printstars: push %rdi mov $.star, %rdi xor %rax, %rax call printf pop %rdi dec %rdi cmp $0, %rdi jg _printstars mov $.line, %rdi xor %rax, %rax call printf pop %rdi pop %rsi ret printstarpyramid: mov %rdi,...
I am trying to implement a search function for a binary search tree. I am trying...
I am trying to implement a search function for a binary search tree. I am trying to get the output to print each element preceding the the target of the search. For example, in the code when I search for 19, the output should be "5-8-9-18-20-19" Please only modify the search function and also please walk me through what I did wrong. I am trying to figure this out. Here is my code: #include<iostream> using namespace std; class node {...
I am trying to make a program in Python that opens a file and tells you...
I am trying to make a program in Python that opens a file and tells you how many lines, vowels, consonants, and digits there are in the file. I got the print out of lines, digits, and consonants, but the if statement I made with the vowels list isn't recognizing them. How can I make the vowels go through the if statement with the list? Am I using the wrong operator? Here is my program #Assignment Ch7-1 #This program takes...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT