Settings handling

This commit is contained in:
Przemek Grondek 2014-07-21 12:36:43 +02:00
parent 0d67614456
commit d2ef2a958c
5 changed files with 11 additions and 26 deletions

View file

@ -31,9 +31,9 @@ public class DatabaseActivity extends Activity {
// automatically handle clicks on the Home/Up button, so long // automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml. // as you specify a parent activity in AndroidManifest.xml.
//TODO Handling menu
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.action_settings) { if (id == R.id.action_settings) {
Static.startSettings(this);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View file

@ -23,25 +23,4 @@ public class EntriesActivity extends Activity {
} }
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
//TODO Handling menu
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
} }

View file

@ -33,11 +33,9 @@ public class MainActivity extends Activity {
// automatically handle clicks on the Home/Up button, so long // automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml. // as you specify a parent activity in AndroidManifest.xml.
//TODO Handling menu
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.action_settings) { if (id == R.id.action_settings) {
Intent intent = new Intent(this, SettingsActivity.class); Static.startSettings(this);
startActivity(intent);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View file

@ -1,5 +1,8 @@
package info.nerull7.mysqlbrowser; package info.nerull7.mysqlbrowser;
import android.content.Context;
import android.content.Intent;
import info.nerull7.mysqlbrowser.db.DatabaseConnector; import info.nerull7.mysqlbrowser.db.DatabaseConnector;
/** /**
@ -13,4 +16,9 @@ public class Static {
return false; return false;
return true; return true;
} }
public static void startSettings(Context context){
Intent intent = new Intent(context, SettingsActivity.class);
context.startActivity(intent);
}
} }

View file

@ -35,9 +35,9 @@ public class TableActivity extends Activity {
// automatically handle clicks on the Home/Up button, so long // automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml. // as you specify a parent activity in AndroidManifest.xml.
//TODO Handling menu
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.action_settings) { if (id == R.id.action_settings) {
Static.startSettings(this);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);