Elements. Build native projects for any modern development platform, using the language(s) of your choice. Oxygene (Object Pascal), C#, Swift, Java, Go. | RemObjects Software

ActionBar

Language: Silver, Platform: Cooper, Category: Android
https://github.com/remobjects/ElementsSamples/tree/master/Silver/Cooper/Android/ActionBar

MainActivity.swift

import java.util
import android.app
import android.content
import android.os
import android.util
import android.view
import android.widget

public class MainActivity: Activity {
	
	public override func onCreate(_ savedInstanceState: Bundle!) {

		super.onCreate(savedInstanceState);

		// Set our view from the "main" layout resource
		ContentView = R.layout.main;
	}

	public override func onCreateOptionsMenu(_ menu: Menu!) -> Bool {
		
		let inflater = getMenuInflater();
		inflater.inflate(R.menu.main_activity_actions, menu);
		return super.onCreateOptionsMenu(menu);
	}

	public override func onOptionsItemSelected(_ item: MenuItem!) -> Bool {
		switch (item.getItemId())
		{
			case R.id.action_search:
				openSearch();
				return true;
			case R.id.action_settings:
				openSettings();
				return true;
			default: 
				return super.onOptionsItemSelected(item);
		}
	}
	
	func openSearch() {
		let intent = android.content.Intent(self, typeOf(SearchActivity));
		startActivity(intent);
	}

	func openSettings() {
		let intent = android.content.Intent(self, typeOf(SettingsActivity));
		startActivity(intent);
	}


}