Code Library

Free Source Code and Program Tips

HelloSpinner.java Source 1 package com.example.test; import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.Spinner; public class HelloSpinner extends Activity (@ Overridepublic void onCreate (Bundle savedInstanceState) ( super.onCreate (savedInstanceState); setContentView (R.layout.main); Spinner s = (Spinner) findViewById (R.id.spinner); ArrayAdapter adapter = ArrayAdapter.createFromResource (this, R.array.planets, android.R. layout.simple_spinner_item); adapter.setDropDownViewResource (android.R.layout.simple_spinner_dropdown_item); s.setAdapter (adapter);)) layout-> main.xml 1 <? xml version = "1.0" [...]

1 HelloFormStuff. Java code is as follows 1 package com.example.test; import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.widget.CheckBox; import android.widget.EditText; import android.widget.ImageButton; import android.widget.RadioButton; import android.widget.Toast; import android.widget.ToggleButton; public class HelloFormStuff extends Activity (/ ** Called when the activity is first created. * / @ Override public void onCreate (Bundle savedInstanceState) (super.onCreate (savedInstanceState); [...]

Hello, TimePicker A TimePicker is a Widget that allows the User to Select the time by hour, minute and AM or PM. Start a new project / Activity called HelloTimePicker. Modify HelloTimePicker.java code is as follows: 1 package com.example.test; import java.util.Calendar; import android.app.Activity; import android.app.Dialog; import android.app.TimePickerDialog; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; [...]

Eclipse developed Android, Hello, WebView (study 6)

Hello, WebView A WebView allows you to Create your own Web Browser Activity. In this Tutorial, we'll Create a simple Activity that can View Web pages. Learning Address: http://androidappdocs.appspot.com/guide/tutorials/views/hello-webview.html HelloWebView.java Code 1 package com.example.test; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class HelloWebView extends Activity (WebView webview; / ** Called when the activity is first [...]

Hello, MapView Learning Address: http://androidappdocs.appspot.com/guide/tutorials/views/hello-mapview.html HelloItemizedOverlay.java Code 1 package com.example.test; import java.util.ArrayList; import android.graphics.drawable.Drawable; import com.google.android.maps.ItemizedOverlay; import com.google.android.maps.OverlayItem; public class HelloItemizedOverlay extends ItemizedOverlay (private ArrayList <OverlayItem> mOverlays = new ArrayList <OverlayItem> (); public HelloItemizedOverlay (Drawable defaultMarker) (super (boundCenterBottom (defaultMarker ));// TODO Auto-generated constructor stub) @ Overridepublic int size () (return mOverlays. size ();) public void [...]

Eclipse developed Android, TableLayout (study 4)

Hello, TableLayout A TableLayout is a ViewGroup that will Lay child View elements into rows and columns. Start a new project / Activity called HelloTableLayout. Open the layout file. Make it like so: 1.0 & quot ; encoding = & quot ; utf – 8 & quot ;?& gt ; & lt ; TableLayout xmlns [...]

Hello, RelativeLayout A RelativeLayout is a ViewGroup that allows you to layout child elements in positions relative to the parent or siblings elements. Start a new project / Activity called HelloRelativeLayout. Open the layout file. Make it like so: 1.0 & quot ; encoding = & quot ; utf – 8 & quot ;?& gt [...]

Eclipse developed Android, LinearLayout (study 2)

A LinearLayout is a GroupView that will Lay child View elements vertically or horizontally. Start a new project / Activity called HelloLinearLayout. Open the layout file. Make it like so: 1 <? xml version = "1.0" encoding = "utf-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: orientation = "vertical" android: layout_width = "fill_parent" android: layout_height = [...]

Original From: http://blog.sina.com.cn/s/blog_4ca975460100g5yj.html Android if they had to switch on the screen solution The time in the development of the game, some games are only horizontal screen play, so when placed in the erection of mobile phone, to keep the game screen is still horizontal screen. To achieve this requirement is very simple to configure [...]

Android custom ContentProvider

Custom ContentProvider —- The content provider is used to deal with data sources, while the content parser (ContentResolver) responsible for operating the specific content provider. The data source can be a file or database. More content resolver can simultaneously access the content provider because it is thread – safe. A URI can identify a resource, [...]