Android:Example
lastmod 2024-11-29created 2016-12-093 edits
Tips & Examples related to Android.
Examples
- Android:Example: Simple Android examples.
- Java:Example: Simple Java examples.
- Java:Example:GlobalSetting: Manages setting variables used globally.
- Android.opengl.GLSurfaceView#Example: Android GLSurfaceView Sample.
- Android:Example:DipCalc: Converts between Android dip and pixel units.
- Android:Example:DisplayInfo: Gets Android display device information.
- Android.content.SharedPreferences:Example: Saves/loads Android user information (Preference).
- Android:Example:SpinnerDialog: How to show a SPINNER-TYPE dialog on Android.
- Android:Example:Png2Mp4: Sample program that converts png images to mp4.
- Android:Example:MusicInfo: Sample class that gets music information on Android.
- Android:Example:DirectoryManager: Helps get the list of predefined directories available on Android.
- Android:Example:SocketServer: Sample example of building a Socket Server and Socket Client on Android.
- Java.lang.String:InitialConsonant: Example class for Hangul initial consonant (choseong) search (InitialConsonant)
- Android:Example:ImageAdapter: (Geosoft Roadie Android) List box class with image + string selection (items selectable).
- Android:Example:SpinnerBox: (Geosoft Roadie Android) Class that shows a dialog box with a spinner progress icon.
- Android:Example:NdkOpenGLESGeometry: (Geosoft Roadie Android) Geometry rendering using OpenGLES on the NDK side.
- SMS-Forward: Forwards incoming text messages to another phone, Telegram, or a webhook.
How to get a widget instance
Notes on how to get the instance of a widget control defined in an Activity's Layout XML. Below explains how to get the instance of a TextView. First, the widget must be given an ID. So open the layout XML and add an ID as below.
Add the ID with the android:id attribute, writing the ID name after @+id/. In the case above, TextViewIdName is the ID.) The added ID is automatically added as a property of the R.java class under the gen directory. Then, inside the activity for that layout, you can get the instance with findViewById() as below.
Simple way to add a button click event
A simple way to implement the click event of a Button widget defined in an Activity's Layout XML is as follows. First, use the android:onClick attribute in the Layout and write the name of the Method that will actually be implemented in the activity.
Then add the method inside the activity for that layout.