The concept of a task
A task is a stack of activities. A Task is a stack that contains a lot of activity, which follows the principle of LIFO. In one application, the activity that the user opens successively enters the task.
Look at an example:
Several previous articles described the main three ways to store data in Android applications: Sharedpreferences, internal storage, and external SD card storage. What kind of way do you use it in your application? Here are some suggestions:
1. If
As you've seen in the previous section, Preferenceactivity This class allows users to create and modify preference information at run time. If you want to use these preference information, you need to use the Sharedpreferences class.
1. Continue to
WebView allows you to embed a Web browser in your activity. This is useful if you need to embed some Web content in your application.
The following shows how to load content in a Web page in an activity by encoding.
1. A new project, WebView.
2.
The AnalogClock view shows a mock clock, which has an hour hand and a minute hand. In contrast to the DigitalClock view, it can display a digital analog clock. These two views can only display system time and not allow time for a particular time
Sometimes, the programs we do need to provide some options to enable users to customize their own style of use. For example, you might allow users to automatically save login information, allow users to set a page refresh time, and so on. On the
We can also create another fragment of--dialogfragment. As the name suggests, Dialogfragment is a fragment floating above the activity. Dialogfragment comes in handy when the user's feedback is needed. Similar to using listfragment, you need to
Using Timepicker, you can allow users to select events for the day, including a 24-hour system and a am/pm. The following example will show how to use Timepicker.
1. Create a project: BasicViews4.
2. Code in the Main.xml.
Autocompletetextview and EditText are very similar, in fact, Autocompletetextview is the EditText subclass. With Autocompletetextview, a message pops up automatically when the user is typing. The following example shows how to use
Button,imagebutton,edittext,chcekbox,togglebutton
In addition to the most commonly used textview,android, some other basic controls are provided.
Button
ImageButton
EditText
CheckBox
Radiogroup and RadioButton
ToggleButton
The following
When you create a new Android project, Eclipse usually creates a main.xml file that contains a element.
TextView is used to present text messages to users. This is the most basic control that you will always use
Users can interact with your UI in two levels, one at the activity level and the other in the view level. At the activity level, the activity class exposes some of the methods that you can rewrite. There are some common methods that you can rewrite
So far, in all the chapters, the UI we've seen is implemented through XML. As mentioned before, in addition to using XML, you can use code to implement the UI interface. This approach is useful, such as your UI needs to be generated at runtime. For
In the previous section, menu options are not text. If you want to display both icons and text together, you can use the "|" and Menuitem.show_as_action_with_text constants.
MenuItem mnu1 = menu.add (0, 0, 0, "Item 1");
{
Mnu1.
In addition to displaying the title of the application icon and activity on the left side of the Actionbar, additional items can be displayed on the Actionbar. These added items are called "Action items." These items are shortcuts to some of the
Occasionally, you may want to make sure that your application shows up in a certain direction, horizontal screen mode or vertical screen mode. For example, you might develop a game that runs only under horizontal screen mode. In this case, you can
ScrollView is a special framelayout that allows users to scroll through a list of views that can be used to make more space than the physical display area. One thing to note is that ScrollView can only contain one view or ViewGroup (this viewgroup
Using Absolutelayout, you can specify the exact location of the child view in it. Observe the code in the following main.xml:
Here is the effect chart, using the Android:layout_x and Android_y
By using the elements in Intent-filter, we can group the activities. Suppose you have added a element to the Androidmanifest.xml:
"
In this case, the following code calls the Mybrowseractivity directly:
We already know that an activity invokes another activity by using the intent object. In order to be able to respond to other activity, you also need to configure elements in Androidmanifest.xml, specifying both action and category. For example:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service