Using BottomSheetBehavior with a inner CoordinatorLayout

I have finally released my implementation. Find it on Github or directly from jcenter: compile ‘com.otaliastudios:bottomsheetcoordinatorlayout:1.0.0’ All you have to do is using BottomSheetCoordinatorLayout as the root view for your bottom sheet. It will automatically inflate a working behavior for itself, so don’t worry about it. I have been using this for a long time … Read more

How to handle Touch Events on a Fragment?

I’m not sure if I understood your problem, but I will try to answer this. So to get touch events on fragment I would do this: -in your fragment onCreateView: View view = inflater.inflate(R.layout.fragment_test, container, false); view.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_MOVE){ //do something } return true; } … Read more

EditText in Listview loses focus when pressed on Android 4.x

A classic hack for situations like this is to use a handler and postDelayed(). In your adapter: private int lastFocussedPosition = -1; private Handler handler = new Handler(); public View getView(final int position, View convertView, ViewGroup parent) { // … edittext.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { handler.postDelayed(new … Read more

Android – Hold Button to Repeat Action

This is more independent implementation, usable with any View, that supports touch event: import android.os.Handler; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; /** * A class, that can be used as a TouchListener on any view (e.g. a Button). * It cyclically runs a clickListener, emulating keyboard-like behaviour. First * click is fired immediately, … Read more

HorizontalScrollView within ScrollView Touch Handling

Update: I figured this out. On my ScrollView, I needed to override the onInterceptTouchEvent method to only intercept the touch event if the Y motion is > the X motion. It seems like the default behavior of a ScrollView is to intercept the touch event whenever there is ANY Y motion. So with the fix, … Read more