In this lesson I will show how to create the search filter for the RecyclerView widget. It is not so hard: we need to add the EditText, add the listener for it and to create the filter method inside adapter class.
In this article I will show the RecyclerView example. The RecyclerView widget is recommended for a large lists because the code allows you to create and display the lists is much more efficient and productive.
The ViewHolder Pattern allows to improve the speed of the view rendering. Every call of findViewById() is not so fast and ViewHolder can reduce it. In this pattern we reuse needed View and not call findViewById() for every ListView item. The main principle here is to create the static inner class ViewHolder that contains/hold the needed views. Below you will see the simple example.
In this tutorial I will describe how to create a simple list with ListView widget. Our list will show the animals names. Also we will create the handler for on click event that will shows the selected item using Toast message.
What we need to do:
1. to initialize the ListView widget;
2. to create adapter object: in our case we will use the simple ArrayAdapter
3. to set adapter for our ListView.
The Button is frequently used widget in many android applications. In this post I will describe how to use this simple View element.
In this post you will see the example how to use Android widget EditText in your application. The EditText is using usually when you need to get some data from user. It is like an input field in HTML.
Let’s create a simple application with layout that contains two elements: EditText and Button. The click on the button initilizes the Toast message with text from our EditText.
I think you have already seen in many applications the possibility of “turning” pages/screen using your finger movements to the left or right across the screen. This pattern is called ViewPager. It is easy to create and use, and now we will create a small sample application.
I had a task today to set the cursor position at the end in EditText when it appears with some default text for user. By default the cursor appears before first letter and it’s a little inconvenient for the user. Below you can see the example how to move the cursor at the end of this widget.
In this post I will show the example how to use the AutoCompleteTextView widget in your android app. It’s very simple widget and I think we don’t need to describe it very long:)
In example below we have the simple android app where the main screen has the AutoCompleteTextView widget. When user starts to type something the widget shows the tips we have defined in our code. We will save these tips in strings resources. In real app the sources can be any (text file, sqlite and etc).
Today I spent a lot of time to fix one problem with Android Emulator when I run it on Android Studio. Usually I use real device to test a application but in this case I wanted to debug on moment. I pressed the button “Run”, chose the default Nexus 5 emulator and in several seconds got the error:
D:\android\tools\emulator.exe -netdelay none -netspeed full -avd Nexus_5_API_22_x86
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.
CPU acceleration status: HAX kernel module is not installed!