IT tutorials
 
Mobile
 

Android 3 : Employing Basic Widgets - Assigning Labels

5/9/2013 3:19:17 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

The simplest widget is the label, referred to in Android as a TextView. As in most GUI toolkits, labels are bits of text that can't be edited directly by users. Typically, labels are used to identify adjacent widgets (e.g., a "Name:" label next to a field where the user fills in a name).

In Java, you can create a label by creating a TextView instance. More commonly, though, you will create labels in XML layout files by adding a TextView element to the layout, with an android:text property to set the value of the label itself. If you need to swap labels based on certain criteria, such as internationalization, you may wish to use a string resource reference in the XML instead.

TextView has numerous other properties of relevance for labels, such as the following:

  • android:typeface: Sets the typeface to use for the label (e.g., monospace)

  • android:textStyle: Indicates that the typeface should be made bold (bold), italic (italic), or bold and italic (bold_italic)

  • android:textColor: Sets the color of the label's text, in RGB hex format (e.g., #FF0000 for red)

For example, in the Basic/Label project, you will find the following layout file:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="You were expecting something profound?"
  />

Just that layout alone, with the stub Java source provided by Android's project builder (e.g., android create project), gives you the result shown in Figure 1.

Figure 1. The LabelDemo sample application
 
Others
 
- Symbian OS : Security - Buckle
- Symbian OS : Security - Secure Agent
- iOS SDK : Application Settings - The Settings Bundle (part 4) - PSSliderSpecifier, PSChildPaneSpecifier
- iOS SDK : Application Settings - The Settings Bundle (part 3) - PSMultiValueSpecifier
- iOS SDK : Application Settings - The Settings Bundle (part 2) - Settings Field Types
- iOS SDK : Application Settings - The Settings Bundle (part 1)
- Ipad : Your Calendar - Calendar Options - Changing the Default Calendar
- Ipad : Your Calendar - Editing Appointments, Meeting Invitations
- BlackBerry Bold 9700 and 9650 Series : Email Set Up - BlackBerry Enterprise Server Express
- BlackBerry Bold 9700 and 9650 Series : Email Set Up - Set Up or Adjust Email Accounts from Your Computer
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us