This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FragmentName extends Fragment { | |
ArrayList<songItem> SongItems; | |
ArrayList<genreItem> GenreItems; | |
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
final View view = inflater.inflate(R.layout.fragment_name, container, false); | |
songArrayList songs = new songArrayList(); | |
SongItems = songs.getSongList(); | |
GenreItems = songs.getGenreList(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocationDetailActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.location_detail); | |
//This is where you'll get the Intent extras | |
//Then you'll want to assign those strings and integer values to your TextViews, ImageViews just like you would with any other activity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Okay so this is the basic concept I used in my Now Playing activity. | |
//Essentially we want to get the current index of the selected song in the Arraylist | |
//Then create a temporary reference and either add to it or subract from it | |
//And then refresh the TextViews based on the new position in the ArrayList | |
//First things first, make sure you have global variables for your TextViews and your ArrayList itself. | |
ArrayList<songs> SongItems = new ArrayList<>(); | |
//This is called after using .setOnClickListener(this) -- and implementing View.OnClickListener on my public class | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (mCurrentBookUri == null) { | |
Toast.makeText(this,getString(R.string.not_save_msg), Toast.LENGTH_SHORT).show(); | |
} | |
if (TextUtils.isEmpty(nameString)){ | |
Toast.makeText(this, getString(R.string.enter_name_req),Toast.LENGTH_SHORT).show(); | |
return; | |
} | |
if (TextUtils.isEmpty(priceString)){ | |
Toast.makeText(this, getString(R.string.enter_price_req),Toast.LENGTH_SHORT).show(); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//I actually have this separated out into a model class, but it could technically be internal like this | |
internal class NavigationItem { | |
public string Title { get; set; } ////This pairs with ShellItem.Title | |
public DataTemplate Template { get; set; } ////This pairs with ShellItem.ContentTemplate | |
public ImageSource Image { get; set; } ////This pairs with ShellItem.Icon | |
public string Route { get; set; } ////This pairs with ShellItem.Route | |
public List<ShellContent> Tabs { get; set; } ////This pairs with ShellItem.Tab | |
public bool HasImage => Image != null; ////These are optional, and just for validation purpose | |
public bool HasNavigation => Template != null; ////These are optional, and just for validation purpose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Shell.ItemTemplate> | |
<DataTemplate> | |
<ContentView> | |
Bindable Properties: Title, Icon | |
</ContentView> | |
</DataTemplate> | |
</Shell.ItemTemplate> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NavigationFlyoutItemTemplateSelector : DataTemplateSelector | |
{ | |
public DataTemplate NavigationHeaderTemplate { get; set; } | |
public DataTemplate NavigationItemTemplate { get; set; } | |
protected override DataTemplate OnSelectTemplate(object item, BindableObject container) | |
{ | |
//Returning null, because at this point I'm not sure how to select the correct template | |
return null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Style x:Key="FlyoutHeaderStyle" TargetType="Label"> | |
<Setter Property="FontSize" Value="Default" /> | |
<Setter Property="Margin" Value="15,0" /> | |
<Setter Property="TextColor" Value="Black" /> | |
<Setter Property="FontAttributes" Value="Bold" /> | |
<Setter Property="HorizontalOptions" Value="Start" /> | |
</Style> | |
<Style x:Key="FlyoutItemStyle" TargetType="Label"> | |
<Setter Property="FontSize" Value="Default" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Shell | |
... | |
ItemTemplate="{StaticResource FlyoutTemplateSelector}" | |
... > |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override DataTemplate OnSelectTemplate(object item, BindableObject container) | |
{ | |
// Returning something like this will look at the route declaration and determine if it's a header or item | |
return ((FlyoutItem)item).Route.StartsWith("Header") ? NavigationHeaderTemplate : NavigationItemTemplate; | |
} |
OlderNewer