[android-developers] TextView getting cut in some resolutions

2017-02-01 Thread Amitai Rosenberg


I have a RecyclerView which consists of CardViews that have a TextView and 
an ImageView, among some other layouts.
The problem is, in some screen resolutions the TextView gets cut off or 
shoved to the next line, which I don't want.
In other resolutions, the TextView has plenty of room.


Small Resolutions:




High Resolutions:



How do I organize the layout so that there is enough room for the TextView, 
and the ImageView will be sized accordingly?

This is my xml for the RecyclerView items:


http://schemas.android.com/apk/res/android"xmlns:cardview="http://schemas.android.com/apk/res-auto"android:id="@+id/zmanCard"android:layout_width="match_parent"android:layout_height="50dp"android:layout_gravity="center_horizontal"android:gravity="center_horizontal"cardview:cardUseCompatPadding="false"cardview:cardPreventCornerOverlap="false"cardview:cardCornerRadius="4dp"cardview:cardElevation="2dp;>













-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/74c5e6ad-7c85-4f73-85fb-be5b7e0f7e7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Android Spinner in Toolbar Arrow

2016-08-20 Thread Amitai Rosenberg


I want to have a Spinner in my Toolbar. However, the Spinner doesn't have 
any dropdown arrow, as the default Android Spinner does.

How do I make it have an arrow?

This is my code:

 
  

Fragment where I show the spinner:

 var spinner = Activity.FindViewById(Resource.Id.Location_Spinner);
 var adapter = ArrayAdapter.CreateFromResource(Activity, 
Resource.Array.locations_array, Android.Resource.Layout.SimpleSpinnerItem);
 
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
 spinner.Adapter = adapter;

Any ideas why there isn't an arrow?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/c39f7378-b30e-41db-8b18-30018594f224%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Android Time Preference Dialog with Support Library

2016-08-11 Thread Amitai Rosenberg
I'm confused about using Android Preferences with the Support v7 or v14 
library.
It seems like every couple of months Google changes the API.
I'm trying to create a Time Preference Dialog. However, my current one 
doesn't work with the Support Library.

public class TimePickerPreference : DialogPreference
{
private int lastHour = 0;
private int lastMinute = 0;
private TimePicker picker = null;

public static int GetHour(string time)
{
string[] pieces = time.Split(':');

return Convert.ToInt32(pieces[0]);
}

public static int GetMinute(string time)
{
string[] pieces = time.Split(':');

return Convert.ToInt32(pieces[1]);
}

public TimePickerPreference(Context ctxt, IAttributeSet attrs) : base(ctxt, 
attrs)
{

}


protected override View OnCreateDialogView()
{
picker = new TimePicker(Context);
picker.SetIs24HourView(Java.Lang.Boolean.True);
return picker;
}

protected override void OnBindDialogView(View v)
{
base.OnBindDialogView(v);

picker.Hour = lastHour;
picker.Minute = lastMinute;
}


protected override void OnDialogClosed(bool positiveResult)
{
base.OnDialogClosed(positiveResult);

if (positiveResult)
{
lastHour = picker.Hour;
lastMinute = picker.Minute;

string time = lastHour + ":" + lastMinute;
if (lastMinute.ToString().Length == 1)
time = lastHour + ":" + "0" + lastMinute;

if (CallChangeListener(time))
{
PersistString(time);
}

Title = "שעת תזכורת: " + time;
}
}

protected override Java.Lang.Object OnGetDefaultValue(TypedArray a, int 
index)
{
return a.GetString(index);
}

protected override void OnSetInitialValue(bool restorePersistedValue, 
Java.Lang.Object defaultValue)
{
string time = string.Empty;

if (restorePersistedValue)
{
if (defaultValue == null)
{
time = GetPersistedString("00:00");
}
else
{
time = GetPersistedString(defaultValue.ToString());
}
}
else
{
time = defaultValue.ToString();
}

lastHour = GetHour(time);
lastMinute = GetMinute(time);
}
}


DialogPreference doesn't exist in the support libraries, and what seems to 
be instead is either PreferenceDialogFragment or 
PreferenceDialogFragmentCompat, both of which work differently, and the 
above code doesn't work with them.

I'm really at loss in all of this and would be glad for some help.
Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/04e35cb0-1531-4c9d-9081-e409bd0ab0f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Android Expandable RecyclerView different Card height

2016-07-23 Thread Amitai Rosenberg
Anyone?

On Friday, July 22, 2016 at 4:19:48 PM UTC+3, Amitai Rosenberg wrote:
>
> I have a RecyclerView that contains a list of cards, which expand into 
> child cards.
> Each card has different text. I want that when the user clicks on a child 
> card, it expands to show the text inside.
> I tried to measure the target height by using:
>
> view.Measure(ViewGroup.LayoutParams.WrapContent, 
> ViewGroup.LayoutParams.WrapContent);
>
>
> And then expanding the card to the Measured Height (see here 
> <http://stackoverflow.com/questions/4946295/android-expand-collapse-animation>).
>  
> However, it gives the same Measured Height to all of the cards.
>
> Here is my code, which is based on this 
> <https://github.com/bignerdranch/expandable-recycler-view> (more 
> specifically the Xamarin version 
> <https://github.com/frankcalise/XamDroid.ExpandableRecyclerView>):
>
> This is the main Adapter, which creates and binds the parent and the child 
> cards:
>
> public class HalachaExpandableAdapter : 
> ExpandableRecyclerAdapter<HalachaParentViewHolder, HalachaChildViewHolder>, 
> View.IOnClickListener{
> LayoutInflater _inflater;
> bool expand;
> int targetHeight;
> bool wave = false;
>
> public HalachaExpandableAdapter(Context context, List 
> itemList) : base(context, itemList)
> {
> _inflater = LayoutInflater.From(context);
> }
>
> public override void OnBindChildViewHolder(HalachaChildViewHolder 
> childViewHolder, int position, object childObject)
> {
> var halachaChild = (HalachaChild)childObject;
> childViewHolder.halachaChildTitle.Text = 
> halachaChild.Title.ToString();
>
> targetHeight = childViewHolder.halachaChildCard.Height;
> childViewHolder.halachaChildCard.LayoutParameters.Height = 100;
> childViewHolder.halachaChildCard.SetOnClickListener(this);
> expand = childViewHolder.expand;
>
> }
>
> public override void OnBindParentViewHolder(HalachaParentViewHolder 
> parentViewHolder, int position, object parentObject)
> {
> var halacha = (HalachaItem)parentObject;
> parentViewHolder._halachaTitleTextView.Text = halacha.Title();
> parentViewHolder._halachaContentTextView.Text = halacha.Content;
> if (halacha.ChildObjectList.Count == 1)
> wave = true;
> }
>
> public void OnClick(View v)
> {
> if (v.Height == 100)
> {
> AnimationCollapse anim = new AnimationCollapse(v, targetHeight, 
> 100);
> anim.Duration = 300;
> v.StartAnimation(anim);
>
> expand = false;
> }
> else
> {
> AnimationCollapse anim = new AnimationCollapse(v, 100, v.Height);
> anim.Duration = 300;
> v.StartAnimation(anim);
>
> expand = true;
> }
> }
>
> public override HalachaChildViewHolder OnCreateChildViewHolder(ViewGroup 
> childViewGroup)
> {
> var view = _inflater.Inflate(Resource.Layout.halachotListItem, 
> childViewGroup, false);
> return new HalachaChildViewHolder(view);
> }
>
> public override HalachaParentViewHolder 
> OnCreateParentViewHolder(ViewGroup parentViewGroup)
> {
> var view = _inflater.Inflate(Resource.Layout.halachotListHeader, 
> parentViewGroup, false);
> wave = false;
> return new HalachaParentViewHolder(view);
> }}
>
>
> I think this is where the code is needed to be done, but if you need some 
> of the other code of the other classes, I will gladly post them. You can 
> also look at the links above for reference to how this works.
>
> Hope someone can help me.
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/fc68d987-fa7a-41c8-bada-4e06ff2ea216%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Android Expandable RecyclerView different Card height

2016-07-22 Thread Amitai Rosenberg
I have a RecyclerView that contains a list of cards, which expand into 
child cards.
Each card has different text. I want that when the user clicks on a child 
card, it expands to show the text inside.
I tried to measure the target height by using:

view.Measure(ViewGroup.LayoutParams.WrapContent, 
ViewGroup.LayoutParams.WrapContent);


And then expanding the card to the Measured Height (see here 
).
 
However, it gives the same Measured Height to all of the cards.

Here is my code, which is based on this 
 (more 
specifically the Xamarin version 
):

This is the main Adapter, which creates and binds the parent and the child 
cards:

public class HalachaExpandableAdapter : 
ExpandableRecyclerAdapter, 
View.IOnClickListener{
LayoutInflater _inflater;
bool expand;
int targetHeight;
bool wave = false;

public HalachaExpandableAdapter(Context context, List 
itemList) : base(context, itemList)
{
_inflater = LayoutInflater.From(context);
}

public override void OnBindChildViewHolder(HalachaChildViewHolder 
childViewHolder, int position, object childObject)
{
var halachaChild = (HalachaChild)childObject;
childViewHolder.halachaChildTitle.Text = halachaChild.Title.ToString();

targetHeight = childViewHolder.halachaChildCard.Height;
childViewHolder.halachaChildCard.LayoutParameters.Height = 100;
childViewHolder.halachaChildCard.SetOnClickListener(this);
expand = childViewHolder.expand;

}

public override void OnBindParentViewHolder(HalachaParentViewHolder 
parentViewHolder, int position, object parentObject)
{
var halacha = (HalachaItem)parentObject;
parentViewHolder._halachaTitleTextView.Text = halacha.Title();
parentViewHolder._halachaContentTextView.Text = halacha.Content;
if (halacha.ChildObjectList.Count == 1)
wave = true;
}

public void OnClick(View v)
{
if (v.Height == 100)
{
AnimationCollapse anim = new AnimationCollapse(v, targetHeight, 
100);
anim.Duration = 300;
v.StartAnimation(anim);

expand = false;
}
else
{
AnimationCollapse anim = new AnimationCollapse(v, 100, v.Height);
anim.Duration = 300;
v.StartAnimation(anim);

expand = true;
}
}

public override HalachaChildViewHolder OnCreateChildViewHolder(ViewGroup 
childViewGroup)
{
var view = _inflater.Inflate(Resource.Layout.halachotListItem, 
childViewGroup, false);
return new HalachaChildViewHolder(view);
}

public override HalachaParentViewHolder OnCreateParentViewHolder(ViewGroup 
parentViewGroup)
{
var view = _inflater.Inflate(Resource.Layout.halachotListHeader, 
parentViewGroup, false);
wave = false;
return new HalachaParentViewHolder(view);
}}


I think this is where the code is needed to be done, but if you need some 
of the other code of the other classes, I will gladly post them. You can 
also look at the links above for reference to how this works.

Hope someone can help me.
Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/e8502281-98d4-4948-b446-34e6acac88d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Android Palette working only on some of RecyclerView items

2016-06-16 Thread Amitai Rosenberg
Anyone?

On Tuesday, June 14, 2016 at 3:57:37 PM UTC+3, Amitai Rosenberg wrote:
>
> I'm trying to generate a Palette for each CardView I have inside a 
> RecyclerView, and to color the card based on the Palette generated.
> However, for some weird reason, only the last two CardViews of the 
> RecyclerView get colored.
>
>
> This is my code:
>
>
> RecyclerAdapter:
>
> public class RecyclerAdapter : RecyclerView.Adapter, 
> Palette.IPaletteAsyncListener
> {
> private List mBooks;
> private RecyclerView mRecyclerView;
> private Context mContext;
> private int mCurrentPosition = -1;
> private bool isPaletteGenerated = false;
> MyView myHolder;
> public RecyclerAdapter(List books, RecyclerView recyclerView, 
> Context context)
> {
> mBooks = books;
> mRecyclerView = recyclerView;
> mContext = context;
> }
>
> public class MyView : RecyclerView.ViewHolder
> {
> public View mMainView { get; set; }
> public TextView mTitle { get; set; }
> public ImageView mCoverImage { get; set; }
> public int mCoverImageResourceID { get; set; }
> public CardView mCard { get; set; }
>
> public MyView(View view) : base(view)
> {
> mMainView = view;
> }
> }
>
> public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup 
> parent, int viewType)
> {
>
> View bookItem = 
> LayoutInflater.From(parent.Context).Inflate(Resource.Layout.item_book, 
> parent, false);
>
>
> TextView bookTitle = 
> bookItem.FindViewById(Resource.Id.bookTitle);
> ImageView coverImage = 
> bookItem.FindViewById(Resource.Id.coverImage);
> CardView card = bookItem.FindViewById(Resource.Id.card);
>
> MyView view = new MyView(bookItem) { mTitle = bookTitle, 
> mCoverImage = coverImage, mCard = card};
> return view;
> }
>
> public override async void OnBindViewHolder(RecyclerView.ViewHolder 
> holder, int position)
> {
> myHolder = holder as MyView;
> myHolder.mMainView.Click += mMainView_Click;
> myHolder.mTitle.Text = mBooks[position].Title;
> 
> myHolder.mCoverImage.SetImageDrawable(mBooks[position].Cover.Drawable);
> myHolder.mCoverImageResourceID = mBooks[position].imageResourceId;
>
> if (position > mCurrentPosition)
> {
> int currentAnim = Resource.Animation.slide_left_to_right;
> //SetAnimation(myHolder.mMainView, currentAnim);
> mCurrentPosition = position;
> }
>
> Bitmap photo = await 
> BitmapFactory.DecodeResourceAsync(mContext.Resources, 
> myHolder.mCoverImageResourceID);
> BitmapDrawable bitmapDrawable = 
> ((BitmapDrawable)mBooks[position].Cover.Drawable);
> Bitmap image = bitmapDrawable.Bitmap;
>
> var palette = 
> Palette.From(photo).MaximumColorCount(16).Generate(this);
>
>
> }   
>
> public void OnGenerated(Palette palette)
> {
>
> if (palette == null)
> return;
> try
> {
> if (palette.LightVibrantSwatch != null)
> {
> var lightVibrant = new 
> Color(palette.LightVibrantSwatch.Rgb);
> myHolder.mCard.SetCardBackgroundColor(lightVibrant);
> }
> if (palette.DarkVibrantSwatch != null)
> {
> var darkVibrant = new 
> Color(palette.DarkVibrantSwatch.Rgb);
> myHolder.mCard.SetCardBackgroundColor(darkVibrant);
> }
> }
> catch (Exception ex)
> {
>
> }
>
> }
>
> public override int ItemCount
> {
> get { return mBooks.Count; }
> }
> }
>
>
> Fragment in which the RecyclerView is inside:
>
> public override View OnCreateView(LayoutInflater inflater, ViewGroup 
> container, Bundle savedInstanceState)
> {
>
> mRecyclerView = 
> view.FindViewById(Resource.Id.booksRecyclerView);
> mBooks = new List();
> ImageView cover = new ImageView(Activity);
>
> cover.SetImageResource(Resource.Drawable.Torat_Hamachane1);
> mBooks.Add(new Book() { Title = "תורת המחנה א' - הלכות יום ויום", 

[android-developers] Android Palette working only on some of RecyclerView items

2016-06-14 Thread Amitai Rosenberg


I'm trying to generate a Palette for each CardView I have inside a 
RecyclerView, and to color the card based on the Palette generated.
However, for some weird reason, only the last two CardViews of the 
RecyclerView get colored.


This is my code:


RecyclerAdapter:

public class RecyclerAdapter : RecyclerView.Adapter, 
Palette.IPaletteAsyncListener
{
private List mBooks;
private RecyclerView mRecyclerView;
private Context mContext;
private int mCurrentPosition = -1;
private bool isPaletteGenerated = false;
MyView myHolder;
public RecyclerAdapter(List books, RecyclerView recyclerView, 
Context context)
{
mBooks = books;
mRecyclerView = recyclerView;
mContext = context;
}

public class MyView : RecyclerView.ViewHolder
{
public View mMainView { get; set; }
public TextView mTitle { get; set; }
public ImageView mCoverImage { get; set; }
public int mCoverImageResourceID { get; set; }
public CardView mCard { get; set; }

public MyView(View view) : base(view)
{
mMainView = view;
}
}

public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup 
parent, int viewType)
{

View bookItem = 
LayoutInflater.From(parent.Context).Inflate(Resource.Layout.item_book, parent, 
false);


TextView bookTitle = 
bookItem.FindViewById(Resource.Id.bookTitle);
ImageView coverImage = 
bookItem.FindViewById(Resource.Id.coverImage);
CardView card = bookItem.FindViewById(Resource.Id.card);

MyView view = new MyView(bookItem) { mTitle = bookTitle, 
mCoverImage = coverImage, mCard = card};
return view;
}

public override async void OnBindViewHolder(RecyclerView.ViewHolder 
holder, int position)
{
myHolder = holder as MyView;
myHolder.mMainView.Click += mMainView_Click;
myHolder.mTitle.Text = mBooks[position].Title;

myHolder.mCoverImage.SetImageDrawable(mBooks[position].Cover.Drawable);
myHolder.mCoverImageResourceID = mBooks[position].imageResourceId;

if (position > mCurrentPosition)
{
int currentAnim = Resource.Animation.slide_left_to_right;
//SetAnimation(myHolder.mMainView, currentAnim);
mCurrentPosition = position;
}

Bitmap photo = await 
BitmapFactory.DecodeResourceAsync(mContext.Resources, 
myHolder.mCoverImageResourceID);
BitmapDrawable bitmapDrawable = 
((BitmapDrawable)mBooks[position].Cover.Drawable);
Bitmap image = bitmapDrawable.Bitmap;

var palette = 
Palette.From(photo).MaximumColorCount(16).Generate(this);


}   

public void OnGenerated(Palette palette)
{

if (palette == null)
return;
try
{
if (palette.LightVibrantSwatch != null)
{
var lightVibrant = new 
Color(palette.LightVibrantSwatch.Rgb);
myHolder.mCard.SetCardBackgroundColor(lightVibrant);
}
if (palette.DarkVibrantSwatch != null)
{
var darkVibrant = new Color(palette.DarkVibrantSwatch.Rgb);
myHolder.mCard.SetCardBackgroundColor(darkVibrant);
}
}
catch (Exception ex)
{

}

}

public override int ItemCount
{
get { return mBooks.Count; }
}
}


Fragment in which the RecyclerView is inside:

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, 
Bundle savedInstanceState)
{

mRecyclerView = 
view.FindViewById(Resource.Id.booksRecyclerView);
mBooks = new List();
ImageView cover = new ImageView(Activity);

cover.SetImageResource(Resource.Drawable.Torat_Hamachane1);
mBooks.Add(new Book() { Title = "תורת המחנה א' - הלכות יום ויום", Cover 
= cover, imageResourceId = Resource.Drawable.Torat_Hamachane1}); 


mLayoutManager = new GridLayoutManager(Activity, 2);
mRecyclerView.SetForegroundGravity(GravityFlags.CenterHorizontal);
mRecyclerView.SetLayoutManager(mLayoutManager);
SimpleItemAnimator x = null;

mRecyclerView.SetItemAnimator(x);
mAdapter = new RecyclerAdapter(mBooks, mRecyclerView, Activity);
mRecyclerView.SetAdapter(mAdapter);


cover = new ImageView(Activity);
cover.SetImageResource(Resource.Drawable.kitzurTHM);
mBooks.Add(new Book() { Title = "קיצור תורת המחנה - הלכות יום ויום 
ושבת", Cover = cover, imageResourceId = Resource.Drawable.kitzurTHM });

cover = new ImageView(Activity);

Re: [android-developers] Master Detail Flow with Fragment or Activity

2016-06-06 Thread Amitai Rosenberg
OK. Thanks for your help!

On Monday, June 6, 2016 at 9:11:12 AM UTC+3, TreKing wrote:
>
>
> On Wed, Jun 1, 2016 at 12:17 AM, Amitai Rosenberg <amit...@gmail.com 
> > wrote:
>
>> I see. However, I am already using multiple fragments on the same 
>> Activity with the Navigation Drawer, like Google suggests.
>>
>
> I found it easier to navigate to new Activities that extend some 
> NavigationDrawerActivity base then having one uber-Activity that manages 
> *every 
> single fragment* from the navigation drawer. 
>
>>
>> One question though: I am trying to implement a shared content element 
>> transition from my main activity to the details activity. The problem is 
>> that the content on the first activity is inside a fragment, and calling an 
>> intent with a shared element transition to the details activity doesn't 
>> work.  (If I use a fragment for the details this is easier to do).
>>
>> Any ideas?
>>
>
> Sorry, haven't done enough with transitions to help here.
>
>
> -
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago 
> transit tracking app for Android-powered devices
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/ec1d5aca-d414-40d2-bac7-f1d40ddb9a4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Changing between Navigation Drawer fragments is slow

2016-06-02 Thread Amitai Rosenberg
Any ideas? 

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/4573c0f8-1653-4a1f-b5da-f4664c5335a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Changing between Navigation Drawer fragments is slow

2016-06-01 Thread Amitai Rosenberg


I have an app with a Navigation Drawer that uses fragments for each menu 
item.
Each time an item is clicked, I replace the current fragment.

The problem is that it takes a long time to show the new fragment after the 
user clicked.
The fragment that takes the longest to load is a fragment that has also 
tabs inside it with child fragments.
Is there any way I can speed up the loading of the fragments? (Perhaps 
initializing them beforehand, if this is possible?)


Here is my code:


protected override void OnCreate(Bundle bundle)
{
drawerLayout = FindViewById(Resource.Id.drawer_layout);
navigationView = FindViewById(Resource.Id.nav_view);
drawerLayout.DrawerClosed += DrawerLayout_DrawerClosed;
var mainFab = FindViewById(Resource.Id.mainFab);
mainFab.Click += MainFab_Click;

var callFab = FindViewById(Resource.Id.callFab);
callFab.Click += CallFab_Click;
var messageFab = 
FindViewById(Resource.Id.messageFab);
messageFab.Click += MessageFab_Click;
// Initialize the ViewPager and set an adapter
//var pager = FindViewById(Resource.Id.pager);
//pager.Adapter = new TabsFragmentPagerAdapter(SupportFragmentManager, 
fragments, titles);

// Bind the tabs to the ViewPager
//var tabs = FindViewById(Resource.Id.tabs);
//tabs.SetViewPager(pager);

navigationView.NavigationItemSelected += (sender, e) =>
{
e.MenuItem.SetChecked(true);
//react to click here and swap fragments or navigate

switch (e.MenuItem.ItemId)
{
case (Resource.Id.nav_home):
ListItemClicked(0);
break;

case (Resource.Id.nav_halachot):
ListItemClicked(1);
break;

case (Resource.Id.nav_times):
ListItemClicked(2);
break;

case (Resource.Id.nav_siddur):
ListItemClicked(3);
break;
case (Resource.Id.nav_compass):
ListItemClicked(4);
break;

case (Resource.Id.nav_settings):
ListItemClicked(5);
break;
}


drawerLayout.CloseDrawers();
};

if (bundle == null)
{
ListItemClicked(0);
navigationView.Menu.GetItem(0).SetChecked(true);
fragment = new HomeFragment();
SupportFragmentManager.BeginTransaction()
.Replace(Resource.Id.content_frame, fragment)
.Commit();
}
}

 public override void OnBackPressed()
{

if (drawerLayout.IsDrawerOpen((int)GravityFlags.Start))
{
drawerLayout.CloseDrawer((int)GravityFlags.Start);
}
else
{
base.OnBackPressed();
}
}

private void ListItemClicked(int position)
{

switch (position)
{
case 0:
fragment = new HomeFragment();
Title = "Home";
SupportActionBar.Elevation = 8;
break;
case 1:
fragment = new HalachaFragment();
Title = "aaa";
SupportActionBar.Elevation = 0;
break;
case 2:
fragment = new TimesFragment();
Title = "bbb";
SupportActionBar.Elevation = 8;

break;
case 3:
fragment = new SiddurFragment();
Title = "ccc";
SupportActionBar.Elevation = 8;
break;
case 4:
fragment = new CompassFragment();
Title = "ddd";
SupportActionBar.Elevation = 8;
break;
case 5:
fragment = new SettingsFragment();
Title = "eee";
break;
}



}

private void DrawerLayout_DrawerClosed(object sender, 
DrawerLayout.DrawerClosedEventArgs e)
{
SupportFragmentManager.BeginTransaction()
.Replace(Resource.Id.content_frame, fragment).AddToBackStack("BACK")
.Commit();

}


HalachaFragment.cs (The fragment that contains the tabs):


public class HalachaFragment : Fragment{
private ViewPager halachotPager;
private PagerSlidingTabStrip tabs;

public HalachaFragment()
{
this.RetainInstance = true;
}
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);

// Create your fragment here
}

public override View OnCreateView(LayoutInflater inflater, ViewGroup 
container, Bundle savedInstanceState)
{
// Use this to return your custom view for this Fragment

var view = 

Re: [android-developers] Master Detail Flow with Fragment or Activity

2016-05-31 Thread Amitai Rosenberg
I see. However, I am already using multiple fragments on the same Activity with 
the Navigation Drawer, like Google suggests. 

One question though: I am trying to implement a shared content element 
transition from my main activity to the details activity. The problem is that 
the content on the first activity is inside a fragment, and calling an intent 
with a shared element transition to the details activity doesn't work.  (If I 
use a fragment for the details this is easier to do). 

Any ideas?
Thanks! 

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/68fc7f3e-098e-42ee-8cd9-026a1a661711%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Master Detail Flow with Fragment or Activity

2016-05-28 Thread Amitai Rosenberg
Exactly. 

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/8d839899-307e-43e2-b4d4-5cc6ca9f21f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Master Detail Flow with Fragment or Activity

2016-05-28 Thread Amitai Rosenberg
Thanks. It says there like I wrote. My question is- why? Why don't they suggest 
to use a fragment also for a small screen device, and just replace fragments?

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/85bc8f58-3ba4-4a3a-ac57-6f7c21edf354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Master Detail Flow with Fragment or Activity

2016-05-28 Thread Amitai Rosenberg
Thanks. It says there like I wrote. My question is- why? Why don't they suggest 
to use a fragment also for a small screen device, and just replace fragnents?

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/e0aff950-7bf6-4088-8aab-6d5ef10fdac8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Master Detail Flow with Fragment or Activity

2016-05-26 Thread Amitai Rosenberg


I'm making an Android app from which the user can choose content to read.
There is a list of books, and once the user chooses one, it opens a new 
screen with the content, and a second navigation drawer for navigating 
through the book.


I'm not sure if this screen should be a fragment or an Activity.

I see a lot of recommendations to use fragments, but if you choose a 
Master/Detail Flow template in Android Studio, it creates an *Activity* for 
the details (at least for small screen sizes).

Why is this?

I'd be happy for some guidelines and explanations.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/1746c51b-d708-4c33-a4be-550d52599e23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Android table of contents navigation style

2016-05-21 Thread Amitai Rosenberg
Anyone? 

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/1a40ed09-4440-4f32-b995-e95c74689e03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Android table of contents navigation style

2016-05-19 Thread Amitai Rosenberg


Hi all.

I'm making an app which presents reading content to the user.

I want to implement a table of contents navigation.

I'm making my app Material Design, and would like the table of contents to 
be with that same style.


How is it best to do this? I thought of a few options:

1. Navigation Drawer.

2. Expanding Custom ListViews.

3. CardViews. 


Any other ideas?

What would look nice and be the most intuitive for the user?


If anyone has any references to a sample, examples, apps, and images, I 
would be happy. 
I'm looking for ideas.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/57720e2b-5c37-48d8-a464-ca54e99ceee9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Reading and displaying long formatted text documents in Android

2016-05-17 Thread Amitai Rosenberg
Hi all.

I'm developing an Android app which is supposed to present large text files 
(books for example), for the user to browse, read, and search.

My question is as follows: How should I read and present the text file, 
which is currently in either a PDF or Word format, and is formatted?

What file should the text be in (.doc, .txt, .xml, .html)?

What controls/elements and code should I use to read it on the app so that 
it should be presented efficiently and formatted correctly (TextView, 
WebView, PDF reader, or some other way)?
Should I convert it to some type of markup and then parse it?

I'm quite at loss as to what to do...
How is this usually done in Android?

Hope someone can help me.
Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/d6af3012-70aa-4a52-a42f-f30790df9577%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.