public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { swipeLayout = (SwipeDismissFrameLayout)inflater.Inflate(Resource.Layout.activity_settings, container, false); swipeLayout.Swipeable = true; swipeCallback = new SwipeDismissCallback(); swipeCallback.Dismissed += (layout) => { Activity.OnBackPressed(); }; swipeLayout.AddCallback(swipeCallback); return(swipeLayout); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = base.OnCreateView(inflater, container, savedInstanceState) as SwipeDismissFrameLayout; // Inflate the layout for this fragment inflater.Inflate(Resource.Layout.fragment_location_search, view, true); swipeViewLayout = view.FindViewById <SwipeDismissFrameLayout>(Resource.Id.recycler_view_layout); swipeCallback = new SwipeDismissCallback(); swipeCallback.Dismissed += (layout) => { layout.Visibility = ViewStates.Gone; //layout.Reset(); }; swipeViewLayout.AddCallback(swipeCallback); keyboardButton = view.FindViewById <FloatingActionButton>(Resource.Id.keyboard_button); keyboardButton.Click += (sender, e) => { mSearchView.Visibility = ViewStates.Visible; mSearchView.RequestFocus(); ShowInputMethod(mSearchView); }; voiceButton = view.FindViewById <FloatingActionButton>(Resource.Id.voice_button); voiceButton.Click += (sender, e) => { mSearchView.Visibility = ViewStates.Gone; mSearchView.Text = String.Empty; view.RequestFocus(); Intent intent = new Intent(RecognizerIntent.ActionRecognizeSpeech) .PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm) .PutExtra(RecognizerIntent.ExtraPrompt, mActivity.GetString(Resource.String.location_search_hint)); StartActivityForResult(intent, REQUEST_CODE_VOICE_INPUT); }; mProgressBar = view.FindViewById <ProgressBar>(Resource.Id.progressBar); mSearchView = view.FindViewById <EditText>(Resource.Id.search_view); mSearchView.TextChanged += (object sender, TextChangedEventArgs e) => { // If we're using searchfragment // make sure gps feature is off if (Settings.FollowGPS) { Settings.FollowGPS = false; } }; mSearchView.FocusChange += (object sender, View.FocusChangeEventArgs e) => { View v = sender as View; if (e.HasFocus) { ShowInputMethod(v.FindFocus()); } else { HideInputMethod(v); } }; mSearchView.EditorAction += (object sender, TextView.EditorActionEventArgs e) => { if (e.ActionId == ImeAction.Search) { DoSearchAction(); // If we're using searchfragment // make sure gps feature is off if (Settings.FollowGPS) { Settings.FollowGPS = false; } e.Handled = true; } e.Handled = false; }; mRecyclerView = view.FindViewById <WearableRecyclerView>(Resource.Id.recycler_view); // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView mRecyclerView.HasFixedSize = true; // To align the edge children (first and last) with the center of the screen mRecyclerView.EdgeItemsCenteringEnabled = true; // use a linear layout manager mLayoutManager = new WearableLinearLayoutManager(mActivity); mRecyclerView.SetLayoutManager(mLayoutManager); // specify an adapter (see also next example) mAdapter = new LocationQueryAdapter(new List <LocationQueryViewModel>()); mAdapter.ItemClick += ClickListener; mRecyclerView.SetAdapter(mAdapter); return(view); }