Skip to content

Instantly share code, notes, and snippets.

...
public class Splash extends Activity {
private static final int STOPSPLASH = 0;
// Tempo impiegato dalla ImageView calcolato in millisecondi
private static final long SPLASHTIME = 3000;
private ImageView splash;
@Override
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/splash"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/ic_launcher"
public class MainActivity extends Activity {
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
private CharSequence mDrawerTitle;
private CharSequence mTitle;
private String[] mGalaxyTitles;
@Override
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#000"
android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
...
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
....
<item
android:id="@+id/setting"
android:orderInCategory="100"
android:showAsAction="never"
android:title="setting"/>
<item
android:id="@+id/about"
android:orderInCategory="100"
......
// Settare il bottone, e il suo ID
Button btnuno=(Button)findViewById(R.id.button1);
btnuno.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
// Settare l'intento al Click del bottone
Intent openPage1 = new Intent(MainActivity.this,Page1.class);
....
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="99dp"
android:layout_marginTop="79dp"
...
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.alert:
alert();
return true;
// Setta Action Bar
ActionBar actionbar = getActionBar();
// Setta il titolo
actionbar.setTitle("Titolo");
// Setta il sottotitolo
actionbar.setSubtitle("Sottotitolo");
// Setta una icona differente