« Home « Chủ đề tài liệu androi

Chủ đề : tài liệu androi


Có 20+ tài liệu thuộc chủ đề "tài liệu androi"

Lập trình Androi part 01

tailieu.vn

You can have any programming language and development. The tools look different, the frameworks behave differently, and there are more limitations on what you can do with your programs.. You can think of an activity as being the Android analogue for the window or dialog box in a desktop application. Not only can you respond to intents, but you can...

Lập trình Androi part 02

tailieu.vn

To create an Android application, you will need to create a corresponding Android project. This could be an Eclipse project, if you are using Eclipse for Android development. The Android build tools—whether Eclipse-integrated or stand-alone—will turn the contents of your project into an Android package (APK) file, which is the Android application. “table of contents” for your application, listing all...

Lập trình Androi part 03

tailieu.vn

As described in the previous chapter, to work with anything in Android, you need a project. If you are using tools that are not Android-enabled, you can use the android create project script, found in the tools/ directory in your SDK installation. --path /path/to/my/project/dir --activity Now \ --package com.commonsware.android.Now. Open Now.java in your editor and paste in the following code:....

Lập trình Androi part 04

tailieu.vn

While it is technically possible to create and attach widgets to your activity purely through Java code, as we did in the preceding chapter, the more common approach is to use an XML-based layout file. With that in mind, it’s time to break out the XML and learn how to lay out Android activities that way.. What Is an XML-Based...

Lập trình Androi part 05

tailieu.vn

Android’s toolkit is no different in scope, and the basic widgets will provide a good introduction to how widgets work in Android activities.. 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...

Lập trình Androi part 06

tailieu.vn

If you want OK and Cancel buttons to be beneath the rest of the form, next to one another, and flush to the right side of the screen, you need a container. If you want, you can use LinearLayout in much the same way, eschewing some of the other containers. Their combined sizes probably do not exactly match the width...

Lập trình Androi part 07

tailieu.vn

android:layout_toRightOf="@id/label". android:layout_alignParentTop="true"/>. android:id="@+id/ok". android:layout_width="wrap_content". android:layout_height="wrap_content". android:layout_below="@id/entry". android:layout_alignRight="@id/entry". android:text="OK". android:id="@+id/cancel". android:layout_toLeftOf="@id/ok". android:layout_alignTop="@id/ok". android:text="Cancel". TableLayout controls the overall behavior of the container, with the widgets themselves poured into one or more TableRow containers, one per row in the grid.. However, a widget can take up more than one column by including the android:layout_span property, indicating the number of columns the widget spans....

Lập trình Androi part 08

tailieu.vn

Android provides many of the same sorts of widgets, plus others of particular interest for mobile devices (e.g., the Gallery for examining saved photos).. This chapter begins with a look at Android’s adapters, and then introduces its selection widgets.. In the abstract, adapters provide a common interface to multiple disparate APIs. More specifically, in Android’s case, adapters provide a common...

Lập trình Androi part 09

tailieu.vn

xmlns:android="http://schemas.android.com/apk/res/android". public void onCreate(Bundle icicle). selection.setText(items[position]);. selection.setText . public void onTextChanged(CharSequence s, int start, int before, int count). selection.setText(edit.getText());

Lập trình Androi part 10

tailieu.vn

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android". setContentView(R.layout.main);. setListAdapter(new ArrayAdapter<String>(this, R.layout.row, R.id.label, items));. The key difference is that we have told ArrayAdapter that we want to use our custom layout (R.layout.row) and that the TextView where the word should go is known as R.id.label within that custom layout.. use R.layout as a prefix on the base name of the layout XML file ( R.layout.row. Not...

Lập trình Androi part 11

tailieu.vn

selection=(TextView)findViewById(R.id.selection);. selection.setText(items[position]);. TextView label=(TextView)row.findViewById(R.id.label);. label.setText(items[position]);. ImageView icon=(ImageView)row.findViewById(R.id.icon);. Since findViewById() can find widgets anywhere in the tree of children of the row’s root View, this could take a fair number of instructions to execute, particularly if you need to find the same widgets repeatedly.. What would be nice is a way where you can still use the layout XML, yet cache...

Lập trình Androi part 12

tailieu.vn

setContentView(R.layout.main);. android.R.layout.simple_list_item_1, items));. this.delegate=delegate;. return(delegate.getCount());. return(delegate.getItem(position));. return(delegate.getItemId(position));. return(delegate.getView(position, convertView, parent));. delegate.registerDataSetObserver(observer);. return(delegate.hasStableIds());. return(delegate.isEmpty());. return(delegate.getViewTypeCount());. return(delegate.getItemViewType(position));. delegate.unregisterDataSetObserver(observer);. return(delegate.areAllItemsEnabled());. return(delegate.isEnabled(position));. this.ctxt=ctxt;. this.rates=new float[delegate.getCount()];. for (int i=0;i<delegate.getCount();i. this.rates[i]=2.0f;. rate.setNumStars(3);. rate.setStepSize(1.0f);. View guts=delegate.getView(position, null, parent);. layout.setOrientation(LinearLayout.HORIZONTAL);. rate.setLayoutParams(new LinearLayout.LayoutParams(. LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT));. guts.setLayoutParams(new LinearLayout.LayoutParams(. LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));. rate.setOnRatingBarChangeListener(l);. layout.addView(rate);. layout.addView(guts);. layout.setTag(wrap);. rate.setTag(new Integer(position));. rate.setRating(rates[position]);. wrap.setGuts(delegate.getView(position, wrap.getGuts. this.base=base;. this.rate=rate;. this.guts=guts;. View row=inflater.inflate(R.layout.row, null);

Lập trình Androi part 13

tailieu.vn

DatePicker and DatePickerDialog allow you to set the starting date for the selection, in the form of a year, month, and day of month value. Similarly, TimePicker and TimePickerDialog let you set the initial time the user can adjust, in the form of an hour ( 0 through 23 ) and a minute ( 0 through 59. You can indicate...

Lập trình Androi part 14

tailieu.vn

You can define the maximum end of the range—the value that indicates progress is complete—via setMax. The Views/SeekBar API demo from the Android 2.0 SDK. In this setup, a portion of your activity’s screen is taken up with tabs, which, when clicked, swap out part of the view and replace it with something else. Others refer to tabs as the...

Lập trình Androi part 15

tailieu.vn

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android". <Button android:id="@+id/flip_me". <ViewFlipper android:id="@+id/details". flipper.showNext();. However, you can imagine that the ViewFlipper. flipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_in));. flipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_out));. flipper.addView(btn,. flipper.setFlipInterval(2000);. flipper.startFlipping();. After iterating over the funky words, turning each into a Button, and adding the Button as a child of the ViewFlipper, we set up the flipper to automatically flip between children (flipper.setFlipInterval(2000. and to start flipping (flipper.startFlipping();).. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"....

Lập trình Androi part 16

tailieu.vn

The Input Method Framework. Android 1.5 introduced the input method framework (IMF), which is commonly referred to as soft keyboards. In short, if there is no hardware keyboard, an input method editor (IME) will be available to users when they tap an enabled EditText.. This does not require any code changes to your application, as long as the default functionality...

Lập trình Androi part 17

tailieu.vn

others will offer alternate means for triggering the menu to appear, such as the on-screen button used by the Archos 5 Android tablet.. Also, as with many GUI toolkits, you can create context menus for your Android. When the user first presses the Menu button, the icon mode will appear, showing up to the first six menu choices as large,...

Lập trình Androi part 18

tailieu.vn

<menu xmlns:android="http://schemas.android.com/apk/res/android">. <item android:id="@+id/close". android:title="Close". <item android:id="@+id/no_icon". android:title="Sans Icon". <item android:id="@+id/disabled". android:title="Disabled". <group android:id="@+id/other_stuff". <item android:id="@+id/later". android:title="2nd-To-Last". <item android:id="@+id/last". android:title="Last". <item android:id="@+id/submenu". android:title="A Submenu">. <item android:id="@+id/non_ghost". android:title="Non-Ghost". <item android:id="@+id/ghost". android:title="A Ghost". </item>. If you want to detect when an item is chosen, or to reference an item or group from your Java code, be sure to apply an android:id ,...

Lập trình Androi part 19

tailieu.vn

“Hey, can we change this font?” The answer depends on which fonts come with the platform, whether you can add other fonts, and how to apply them to the widget or whatever needs the font change.. xmlns:android="http://schemas.android.com/apk/res/android". Android 1.6 added the ability to create Typeface objects based on TrueType files in the filesystem, such as on the user’s SD card,...

Lập trình Androi part 20

tailieu.vn

(android.webkit). Using the WebView widget itself can be simple or powerful, based on your requirements, as you’ll learn in this chapter.. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android". package com.commonsware.android.browser1;. import android.app.Activity;. import android.os.Bundle;. import android.webkit.WebView;. browser.loadUrl("http://commonsware.com");. <manifest xmlns:android="http://schemas.android.com/apk/res/android". package="com.commonsware.android.browser1">. <uses-permission android:name="android.permission.INTERNET". <activity android:name=".BrowserDemo1". <action android:name="android.intent.action.MAIN". <category android:name="android.intent.category.LAUNCHER". If we fail to add this permission, the browser will refuse to load pages. Figure 13–1. If...