Created
July 28, 2014 04:25
-
-
Save laaptu/4cb395fded9a0700fcdb to your computer and use it in GitHub Desktop.
Edit Text inside scrollview
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
//http://stackoverflow.com/questions/13812892/enable-scrollable-edittext-within-a-scrollview-and-viewflipper/13815747#13815747 | |
EditText EtOne = (EditText) findViewById(R.id.EditText01); | |
EtOne.setOnTouchListener(new OnTouchListener() { | |
@Override | |
public boolean onTouch(View v, MotionEvent event) { | |
if (v.getId() == R.id.comment1) { | |
v.getParent().requestDisallowInterceptTouchEvent(true); | |
switch (event.getAction() & MotionEvent.ACTION_MASK) { | |
case MotionEvent.ACTION_UP: | |
v.getParent().requestDisallowInterceptTouchEvent(false); | |
break; | |
} | |
} | |
return false; | |
} | |
}); | |
//http://stackoverflow.com/questions/16605486/edit-text-not-scrollable-inside-scroll-view | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.MotionEvent; | |
import android.widget.ScrollView; | |
public class VerticalScrollview extends ScrollView{ | |
public VerticalScrollview(Context context) { | |
super(context); | |
} | |
public VerticalScrollview(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs, defStyle); | |
} | |
@Override | |
public boolean onInterceptTouchEvent(MotionEvent ev) { | |
final int action = ev.getAction(); | |
switch (action) | |
{ | |
case MotionEvent.ACTION_DOWN: | |
Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); | |
super.onTouchEvent(ev); | |
break; | |
case MotionEvent.ACTION_MOVE: | |
return false; // redirect MotionEvents to ourself | |
case MotionEvent.ACTION_CANCEL: | |
Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); | |
super.onTouchEvent(ev); | |
break; | |
case MotionEvent.ACTION_UP: | |
Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); | |
return false; | |
default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; | |
} | |
return false; | |
} | |
@Override | |
public boolean onTouchEvent(MotionEvent ev) { | |
super.onTouchEvent(ev); | |
Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment