Skip to main content

Fragment

To enable/disable menu items in Different fragments in same Activity:

@Override

public void onCreate(@Nullable Bundle savedInstanceState)

 {    super.onCreate(savedInstanceState);    setHasOptionsMenu(true); }

@Override

public void onPrepareOptionsMenu(Menu menu) {

    //Disable the SearchView which is enabled in Product Chart    menu.findItem(R.id.action_search).setVisible(false);  // true to enable

}

====================================================


Comments

Popular posts from this blog

To make a ListView to be scrolled inside of ScrollView

To make a ListView to be scrolled inside of ScrollView: lv . setOnTouchListener ( new ListView . OnTouchListener () { @Override public boolean onTouch ( View v , MotionEvent event ) { int action = event . getAction (); switch ( action ) { case MotionEvent . ACTION_DOWN : // Disallow ScrollView to intercept touch events. v . getParent (). requestDisallowInterceptTouchEvent ( true ); break ; case MotionEvent . ACTION_UP : // Allow ScrollView to intercept touch events. v . getParent (). requestDisallowInterceptTouchEvent ( false ); break ; } // Handle ListView touch events. v . onTouchEvent ( event ); return true ; } }); Refer: http://stackoverflow.com/questions/6210895/listview-inside-scrollview-is-not-scrolling-on-android

SearchView using CursorAdapter

Here  MYFRAGMENT is nothing but name of  a Fragment @Override public void onCreateOptionsMenu (Menu menu, MenuInflater inflater) {     inflater.inflate(R.menu.popup, menu);     final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);     final SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();     searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));     searchView.setSubmitButtonEnabled(false);     searchView.setIconifiedByDefault(true);     //       searchView.setOnCloseListener(this);     SearchView. OnQueryTextListener textChangeListener = new SearchView. OnQueryTextListener () {         @Override         public boolean onQueryTextSubmit(String query) {             cartAdapter.getFilter().filter(query);             if (query.length() > 0) {                 SEARCH_QUERY (query);             }             System.out.println("on Cart Search

Useful Link

ANDROID GEMS: http://www.android-gems.com/category https://github.com/matrixxun/ProductTour https://github.com/jcmore2/AppCrash https://github.com/sahildave/Search-View-Layout http://www.android-gems.com/lib/462 https://github.com/Yalantis/FlipViewPager.Draco https://github.com/sacot41/SCViewPager https://github.com/jianghejie/LinkedViewPager https://github.com/manupsunny/PinLock https://github.com/Trinea/android-open-project/tree/master/English%20Version http://javaant.com/viewpager-with-circle-indicator-in-android/#.Vq8nb9V97IV http://androidopentutorials.com/android-image-slideshow-using-viewpager/ Transition Effect https://github.com/kaichunlin/android-transition https://github.com/toddway/MaterialTransitions https://github.com/lgvalle/Material-Animations https://github.com/DesarrolloAntonio/FragmentTransactionExtended https://github.com/takahirom/PreLollipopTransition http://swarmnyc.com/whiteboard/android-frag