Question

Android Development Question: Let’s assume that your App has an EditText control and a Button in...

Android Development Question:

Let’s assume that your App has an EditText control and a Button in a layout. Write a snippet of code such that when the Button is pressed, the virtual keyboard will be hidden.

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

Hi,

Below is the code-

private void hideKeyboard() {   
// Check if no view has focus:
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}

private void showKeyboard() {   
// Check if no view has focus:
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
}

Regards,

Vinay

Add a comment
Know the answer?
Add Answer to:
Android Development Question: Let’s assume that your App has an EditText control and a Button in...
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
  • This assignemnt for Android development using Java Weather Forecaster App Goal: Create an app to display...

    This assignemnt for Android development using Java Weather Forecaster App Goal: Create an app to display a weather forecast for the user’s current location Create the app titled Weather Forecaster The first screen will have a textbox for the user to enter a zip code and a button to submit When the user enters the zip code and clicks the button, the app will navigate to the weather forecast screen. The weather forecast screen will show the current weather for...

  • (Android Studio) (Mobile App Development) Create a spinner that has drop down function on it (NOT...

    (Android Studio) (Mobile App Development) Create a spinner that has drop down function on it (NOT tab view). Place a scroll bar inside the dropdown of the spinner. The categories inside the spinner include: vegetable, fruit, meat, drink. Clicking on each section will pop up a fragment section below. Here, I clicked on the vegetable section, which leads me to a page displaying vegetables and their expiration dates. Note: Post XML and Java codes for both the main activity and...

  • Using Android Studios. Scenario: You recently started working as the mobile app developer for a University...

    Using Android Studios. Scenario: You recently started working as the mobile app developer for a University and have been assigned to build a mobile app that calculates the students' grade. Your app should contain following screens: Screen 1 Labels for subject1, subject2, and subject3 Textboxes for subject1, subject2, and subject3 Labels for MaxGrade, MinGrade, and Avg.Grade Submit button Once user clicks submit button, you need to display letter grade in a label Screen 2 Screen that allows students to register...

  • Question 1 Which one of the following Button control names is a legal C# identifier? a.*Clear*Button*...

    Question 1 Which one of the following Button control names is a legal C# identifier? a.*Clear*Button* b._DisplayOption5Button c.Exit!Button d.delete Record Button Question 2 To add a control to a form, you find it in the Toolbox and then double-click it. a.True b.False    Question 3 When you write the values true or false in code, they must be written in all lowercase letters. a.True b.False Question 4 Single quotation marks can be used in program code to mark the beginning...

  • Q) MyBooks is an android application has a homepage "Activity_MyBooks.xml" that shows a simple li...

    Q) MyBooks is an android application has a homepage "Activity_MyBooks.xml" that shows a simple list. This list displays only the book title for each book in the user’s book database. The database has a table name “Books” which has the following fields (Book_id, BookTitle, Author, Year). This App connected to the Database by BookstDataSource class and BooksDBHelper class. Explain the following questions on your own words and no need to write a code. Explain how to create the Layout for...

  • Create a new project in BlueJ and name it LastName-lab8-appstore, e.g., Smith-lab8-appstore. If your App class from Lab 4 is fully functional, copy it into the project. (You can drag a file from File...

    Create a new project in BlueJ and name it LastName-lab8-appstore, e.g., Smith-lab8-appstore. If your App class from Lab 4 is fully functional, copy it into the project. (You can drag a file from File Explorer onto the BlueJ project window.) Otherwise, use the instructor's App class: Create a new class using the "New Class..." button and name it App. Open the App class to edit the source code. Select and delete all the source code so that the file is...

  • The question asks you to assume that your input file is an English text that may...

    The question asks you to assume that your input file is an English text that may contain any character that appears on keyboard of a computer. The task is to read each character from the input file and after encrypting it by adding an integer value n (0 < n < 128) to the character, to write the encrypted character to output file. We are supposed to use command line arguments and utilize argc, and argv parameters in main function...

  • Use visual studios language C++ to creat Form1 and Designer Form for question below 3. Form...

    Use visual studios language C++ to creat Form1 and Designer Form for question below 3. Form has three textboxes, two for input and one for output. Form also has five buttons, marked, ‘+’, ‘-’, ‘*’, ‘/’, ‘C’ respectively. User enters integers into the two textboxes, and clicks one of the four buttons (+, - , *, /). The third textbox shows the result of the corresponding operation. For example, if user entered 10 into the first textbox and 2 into...

  • C# Question. Please do a lot of documenting of what your code did and thorough explaining...

    C# Question. Please do a lot of documenting of what your code did and thorough explaining in your // comments. A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new system. You’re to write an app to assign seats on each flight of the airline’s only plane (capacity: 10 seats). Display the following alternatives: Please enter 1 for First Class or 2 for Economy. If the user types...

  • User interfaces are a critical part of any system. In this lesson, a Graphical User Interface...

    User interfaces are a critical part of any system. In this lesson, a Graphical User Interface (GUI) is created. The code generated will link the components to the action. Assignment: Create a Graphical User Interface that has two buttons and a textArea (See Examples 12.3 and Example 12.4). figure 1 Create a String array to store the following messages (Enter your name where it says YourName). "Congratulations YourName!nYou completed the Java class. nYou learned to write Java programs with commonly...

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
ADVERTISEMENT