Android Studio - Action Bar e progettazione. come realizzarla
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Aggiorna"
android:id="@+id/aggiorna"/>
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Aggiorna"
android:id="@+id/aggiorna"
android:orderInCategory="100"
/>
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:title="Aggiorna"
android:id="@+id/aggiorna"
android:orderInCategory="100"
app:showAsAction="ifRoom"
/>
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:title="Aggiorna"
android:id="@+id/aggiorna"
android:orderInCategory="100"
app:showAsAction="ifRoom"
android:icon="@drawable/aggiorna"
/>
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:title="Aggiorna"
android:id="@+id/aggiorna"
android:orderInCategory="100"
app:showAsAction="ifRoom"
android:icon="@drawable/aggiorna"
/>
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:title="Aggiorna"
android:id="@+id/aggiorna"
android:orderInCategory="100"
app:showAsAction="ifRoom"
android:icon="@drawable/aggiorna"
/>
<item android:title="Download"
android:id="@+id/download"
android:orderInCategory="100"
app:showAsAction="ifRoom"
android:icon="@drawable/download"
/>
<item android:title="Copia"
android:id="@+id/copia"
android:orderInCategory="100"
app:showAsAction="ifRoom"
android:icon="@drawable/copy"
/>
<item android:title="Upload"
android:id="@+id/upload"
android:orderInCategory="100"
app:showAsAction="ifRoom"
android:icon="@drawable/upload"
/>
</menu>
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId())
{
case R.id.aggiorna:
Toast.makeText(this, "Aggiorna", Toast.LENGTH_SHORT).show();
break;
}
return super.onOptionsItemSelected(item);
}
switch (item.getItemId())
{
case R.id.aggiorna:
Toast.makeText(this, "Aggiorna", Toast.LENGTH_SHORT).show();
break;
case R.id.download:
Toast.makeText(this, "Download", Toast.LENGTH_SHORT).show();
break;
case R.id.upload:
Toast.makeText(this, "Carica", Toast.LENGTH_SHORT).show();
break;
case R.id.copia:
Toast.makeText(this, "Copia", Toast.LENGTH_SHORT).show();
break;
}
return super.onOptionsItemSelected(item);
Mentre nell’onCreate()
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle("Welcome");
actionBar.setSubtitle("Benvenuto nella tua App");
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle("Welcome");
actionBar.setSubtitle("Benvenuto nella tua App");
actionBar.setIcon(R.drawable.lte);
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle("Welcome");
actionBar.setSubtitle("Benvenuto nella tua App");
actionBar.setIcon(R.drawable.lte);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);