Tag Archives: code

20,958 views

onSensorChanged Android example

Sensor, getSystemService(), getSensorList(), getDefaultDisplay(), WindowManager, Surface.ROTATION_0, onAccuracyChanged() Android sample. public class _MotionActivity extends Activity implements SensorEventListener { private float mSensorX; private float mSensorY; private Display mDisplay; private SensorManager sm; private PowerManager mPowerManager; private WindowManager mWindowManager;   TextView textview;   @Override … Continue reading

Posted in Android Examples Code | Tagged , , | Comments Off on onSensorChanged Android example
2,449 views

Get SensorManager PowerManager WindowManager Display Android example

private SensorManager mSensorManager; private PowerManager mPowerManager; private WindowManager mWindowManager; private Display mDisplay;   // onCreate @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);   // Get an instance of the SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);   // Get an instance of … Continue reading

Posted in Android Software Download | Tagged , | Comments Off on Get SensorManager PowerManager WindowManager Display Android example
18,149 views

Change background color dynamically View TableRow setBackgroundColor Android example

How change background color of View Android sample. MainActivity.java public class MainActivity extends Activity { TextView hTextView; TableRow hTableRow; Button hButton, hButtonStop; private Handler mHandler = new Handler(); private int nCounter = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); … Continue reading

Posted in Android Examples Code | Tagged , , , , , , | Comments Off on Change background color dynamically View TableRow setBackgroundColor Android example
6,267 views

Preferences settings save open read write application Android example

Android app setup preferences, settings, open, read, write, onStop(), onPause(), getSharedPreferences(), SharedPreferences.Editor getInt(), getBoolean(), getString() , putInt(), putString(), putBoolean() example source code.   import android.content.SharedPreferences;   public class MainClass extends Activity { public static final String PREFERENCES_NAME = "MyPrefsFile"; String … Continue reading

Posted in Android Examples Code | Tagged , , , , , , , , | Comments Off on Preferences settings save open read write application Android example
8,705 views

Spinner ComboBox DropDown set on selected item listener setOnItemSelectedListener Java Android example

Spinner, ArrayAdapter, setOnItemSelectedListener, onItemSelected, setDropDownViewResource MainClass.java public class Vypocet extends Activity { Spinner hSpinnerMetry; // ……. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);   hSpinnerMetry = (Spinner) findViewById(R.id.idSpinnerMetry); ArrayAdapter<CharSequence> adapterMetry = ArrayAdapter.createFromResource( this, R.array.metry_array, android.R.layout.simple_spinner_item); adapterMetry.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); hSpinnerMetry.setAdapter(adapterMetry);   hSpinnerMetry.setOnItemSelectedListener( new … Continue reading

Posted in Android Examples Code | Tagged , , , , , , | Comments Off on Spinner ComboBox DropDown set on selected item listener setOnItemSelectedListener Java Android example
23,071 views

Formatting a Number to String NumberFormat DecimalFormat locale Java Android example code

NumberFormat, DecimalFormat, format(), locale format Java Androidexample source code NumberFormat numberFormat = new DecimalFormat("##"); String str = numberFormat.format(-01234.567); // -1235 System.out.print(str + "\n");   str = numberFormat.format(00); // 0 System.out.print(str + "\n");   numberFormat = new DecimalFormat("##00"); str = numberFormat.format(0); … Continue reading

Posted in Android Examples Code | Tagged , , , , , | Comments Off on Formatting a Number to String NumberFormat DecimalFormat locale Java Android example code
19,710 views

TableRow TableLayout table row add delete remove removeview addview Android example

TableRow TableLayout table row add delete remove removeview addview get table row index indexOfChild create table row dynamically TextView dynamically Android example Main.java TableLayout table = (TableLayout)findViewById(R.id.table); TableRow row = (TableRow)findViewById(R.id.row);   // get table row index android. int nIndex … Continue reading

Posted in Android Examples Code | Tagged , , , , , | Comments Off on TableRow TableLayout table row add delete remove removeview addview Android example
65,425 views

Spinner ComboBox DropDown List Android example code

Spinner in Android application is equivalent of ComboBox in WinApi. Spinner get selected item to string example. Spinner get selected item position to int example. Main activity class MainComboBox.java public class MainComboBox extends Activity { @Override public void onCreate(Bundle savedInstanceState) … Continue reading

Posted in Android Examples Code | Tagged , , , , | Comments Off on Spinner ComboBox DropDown List Android example code
7,902 views

Create array of strings in xml file Android example

Example source code for Android developers how create array of strings in *.xml file. You can using array of strings in Spinner ( combobox – dropdown list ) or ListView etc. <resources> <string-array name="colors"> <item>red</item> <item>orange</item> <item>yellow</item> <item>green</item> <item>blue</item> </string-array> … Continue reading

Posted in Android Examples Code, Array,List,Collections | Tagged , , , | Comments Off on Create array of strings in xml file Android example
49,674 views

Start Activity from ListView item click Android example

How start certain Activity if user clicked to ListView item Start Activity from list – launches other activities from list – latest variant!!!! public class Main extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);   try { setContentView(R.layout.main); … Continue reading

Posted in Android Examples Code | Tagged , , , , , , | Comments Off on Start Activity from ListView item click Android example