Permalink
Browse files

ActionBar menu added

  • Loading branch information...
iks111 committed May 7, 2017
1 parent db3594f commit 386df7738060d8871cca65830ed5ef186ca9e62f
@@ -3,6 +3,7 @@
using Android.Content;
using Android.Widget;
using Android.OS;
using Android.Views;
using ActionBar = Android.App.ActionBar;
namespace MoneyBack
@@ -20,6 +21,23 @@ protected override void OnCreate(Bundle bundle)
}
public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.ActionBarMenu, menu);
return base.OnPrepareOptionsMenu(menu);
}
public override bool OnOptionsItemSelected(IMenuItem item)
{
if (item.ItemId == Resource.Id.menuAdd)
{
OpenAddingNewPerson();
return true;
}
return base.OnOptionsItemSelected(item);
}
private void InitializeTabs()
{
this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
@@ -33,9 +51,7 @@ void AddTab(string tabText, Fragment view)
{
var tab = this.ActionBar.NewTab();
tab.SetText(tabText);
// tab.SetIcon(Resource.Drawable.ic_tab_white);
// must set event handler before adding tab
tab.TabSelected += delegate (object sender, ActionBar.TabEventArgs e)
{
var fragment = this.FragmentManager.FindFragmentById(Resource.Id.tabFragmentsContainer);
@@ -58,6 +74,7 @@ protected override void OnStart()
protected override void OnResume()
{
base.OnResume();
}
protected override void OnPause()
@@ -76,7 +93,7 @@ protected override void OnDestroy()
}
private void _btnPeople_Click(object sender, EventArgs e)
private void OpenAddingNewPerson()
{
var intent = new Intent(this, typeof(PeopleActivity));
StartActivity(intent);
@@ -52,6 +52,22 @@
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Reference Include="Xamarin.Android.Support.Annotations, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Xamarin.Android.Support.Annotations.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Annotations.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Xamarin.Android.Support.Compat.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Compat.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.Core.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Xamarin.Android.Support.Core.UI.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Core.UI.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v7.RecyclerView, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Xamarin.Android.Support.v7.RecyclerView.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Entities\Person.cs" />
@@ -96,15 +112,26 @@
<SubType>Designer</SubType>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\menu\ActionBarMenu.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.props'))" />
<Error Condition="!Exists('packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.targets'))" />
<Error Condition="!Exists('packages\Xamarin.Android.Support.Annotations.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Annotations.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Xamarin.Android.Support.Annotations.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Annotations.targets'))" />
<Error Condition="!Exists('packages\Xamarin.Android.Support.Compat.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Compat.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Xamarin.Android.Support.Compat.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Compat.targets'))" />
<Error Condition="!Exists('packages\Xamarin.Android.Support.Core.UI.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Core.UI.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Xamarin.Android.Support.Core.UI.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Core.UI.targets'))" />
<Error Condition="!Exists('packages\Xamarin.Android.Support.v7.RecyclerView.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.v7.RecyclerView.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Xamarin.Android.Support.v7.RecyclerView.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.v7.RecyclerView.targets'))" />
</Target>
<Import Project="packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.targets" Condition="Exists('packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.targets')" />
<Import Project="packages\Xamarin.Android.Support.Annotations.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Annotations.targets" Condition="Exists('packages\Xamarin.Android.Support.Annotations.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Annotations.targets')" />
<Import Project="packages\Xamarin.Android.Support.Compat.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Compat.targets" Condition="Exists('packages\Xamarin.Android.Support.Compat.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Compat.targets')" />
<Import Project="packages\Xamarin.Android.Support.Core.UI.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Core.UI.targets" Condition="Exists('packages\Xamarin.Android.Support.Core.UI.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Core.UI.targets')" />
<Import Project="packages\Xamarin.Android.Support.v7.RecyclerView.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.v7.RecyclerView.targets" Condition="Exists('packages\Xamarin.Android.Support.v7.RecyclerView.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.v7.RecyclerView.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
@@ -65,6 +65,8 @@ private async void _btnSavePerson_Click(object sender, EventArgs e)
else
Toast.MakeText(this, $"Person saved, details: {person}", ToastLength.Long).Show();
this.Finish();
}
private async Task<int> InsertPerson(Person person)
@@ -22,13 +22,17 @@ public override void OnActivityCreated(Bundle savedInstanceState)
{
base.OnActivityCreated(savedInstanceState);
InitializePeopleList(savedInstanceState);
InitializePeopleList();
}
protected async void InitializePeopleList(Bundle savedInstanceState)
public override void OnStart()
{
base.OnCreate(savedInstanceState);
base.OnStart();
InitializePeopleList();
}
protected async void InitializePeopleList()
{
_peopleList = await GetPeopleAsync();
this.ListAdapter = new ArrayAdapter<string>(Activity, Android.Resource.Layout.SimpleExpandableListItem1, _peopleList.ConvertAll(p => p.ToString()));

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<com.refractored.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:id="@+id/fab"
fab:fab_colorNormal="@color/primary"
fab:fab_colorPressed="@color/primary_pressed"
fab:fab_colorRipple="@color/ripple"/>
</FrameLayout>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menuAdd"
android:title="@string/menuAddTitle"/>
</menu>
@@ -9,4 +9,5 @@
<string name="btnSavePerson">Zapisz osobę</string>
<string name="btnPeopleList">Lista osób</string>
<string name="peopleListTitle">Lista osób</string>
<string name="menuAddTitle">Dodaj</string>
</resources>
@@ -9,4 +9,5 @@
<string name="btnSavePerson">Save person</string>
<string name="btnPeopleList">List of people</string>
<string name="peopleListTitle">List of people</string>
<string name="menuAddTitle">Add</string>
</resources>
Oops, something went wrong.

0 comments on commit 386df77

Please sign in to comment.