久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 ScrollView 內滾動 EditText

Scrolling EditText inside ScrollView(在 ScrollView 內滾動 EditText)
本文介紹了在 ScrollView 內滾動 EditText的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個討厭的問題.我在 ScrollView 中有 EditText(8 行).當我試圖在 EditText 中滾動文本時,它的行為并不穩定.有時它在滾動,有時它沒有集中注意力.

I have a nasty problem. I have EditText(8 lines) inside ScrollView. And when I'm trying to scroll text in EditText it's behavior is not stable. Sometimes it's scrolling, some times it's not taking focus.

這是我的布局文件,讓我的問題更清楚:

This is my layout file, to make my question more clear:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="8dp" >

    <TextView
        android:id="@+id/wo_task_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/no_description" />

    <TextView
        android:id="@+id/wo_task_description"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/no_description" />

    <TextView
        android:id="@+id/wo_task_comments_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="@string/comments" />

    <Button
        android:id="@+id/wo_task_select_comment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/select_comment_from_template" />

    <EditText
        android:id="@+id/wo_task_comments"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="top|left"
        android:hint="@string/enter_your_comment_here"
        android:lines="8"
        android:maxLines="10"
        android:minLines="6"
        android:scrollbars="vertical"
        android:singleLine="false" />
</LinearLayout>

我知道我遇到這個問題是因為將一個可滾動控件放在另一個控件中,但我不知道該怎么做.所以,如果可以的話,請幫助我.

I understand that I'm having this issue because of holding one scrollable control inside another, yet I don't know what to do with this. So, please help me if you can.

提前致謝.

public void initComments(final View view) {
    EditText comment = (EditText) view.findViewById(R.id.wo_task_comments);

    comment.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(final View v, final MotionEvent motionEvent) {
            if (view.getId() == R.id.wo_task_comments) {
                view.getParent().requestDisallowInterceptTouchEvent(true);
                switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
                case MotionEvent.ACTION_UP:
                    view.getParent().requestDisallowInterceptTouchEvent(
                            false);
                    break;
                }
            }
            return false;
        }
    });

    comment.setText(currentTask.getComment() + "very very long comment"
            + "very very long comment
" + "very very long comment
"
            + "very very long comment
" + "very very long comment
"
            + "very very long comment");
}

我試過了,沒有結果.我仍然無法滾動我的編輯框.

I've tried this, and no result. I'm still unable to scroll my editbox.

推薦答案

試試:

@Override
public void onCreate(Bundle savedInstanceState) {
    .....  
    EditText et = (EditText)findViewById(R.id.wo_task_comments);
    et.setOnTouchListener(this);
    .....
}

@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    if(view.getId() == R.id.wo_task_comments){
        view.getParent().requestDisallowInterceptTouchEvent(true);
        switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_UP:
                view.getParent().requestDisallowInterceptTouchEvent(false);
                break;
        }
    }
    return false;
}

在你的情況下:

public class MyActivity extends Activity  {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    initComments(findViewById(R.id.YOUR_MAIN_LAYOUT_ID));  
}


public void initComments(final View view) {
    EditText comment = (EditText) view.findViewById(R.id.wo_task_comments);

    comment.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(final View v, final MotionEvent motionEvent) {
            if (v.getId() == R.id.wo_task_comments) {
                v.getParent().requestDisallowInterceptTouchEvent(true);
                switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
                    case MotionEvent.ACTION_UP:
                        v.getParent().requestDisallowInterceptTouchEvent(
                                false);
                        break;
                }
            }
            return false;
        }
    });

    comment.setText("very very long comment"
            + "very very long comment
" + "very very long comment
"
            + "very very long comment
" + "very very long comment
"
            + "very very long comment
" + "very very long comment
"
            + "very very long comment
" + "very very long comment
"
            + "very very long comment
" + "very very long comment
"
            + "very very long comment
" + "very very long comment
"
            + "very very long comment
" + "very very long comment
"
            + "very very long comment
" + "very very long comment
"
            + "very very long comment");
}

}

這篇關于在 ScrollView 內滾動 EditText的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 超碰97免费 | 九九综合 | 中文字幕在线观 | 免费成人av | 日韩精品一区二区三区中文在线 | av黄色免费在线观看 | 噜久寡妇噜噜久久寡妇 | 天天操天天干天天曰 | 午夜影院在线观看 | 日本久久一区 | 精品久久国产老人久久综合 | 免费观看www7722午夜电影 | 欧美激情视频一区二区三区免费 | 亚洲综合国产 | 国产伦精品一区二区三区视频金莲 | 久久久久久91 | 99re6在线视频精品免费 | 天天插天天操 | 久久国产精彩视频 | 久久久久国产一区二区三区四区 | av手机在线免费观看 | 中文字幕在线精品 | 老牛嫩草一区二区三区av | 天天摸天天干 | 成人精品视频 | 精品国产乱码久久久久久闺蜜 | 成人欧美一区二区三区在线观看 | 亚州国产 | 一区二区在线 | 免费精品在线视频 | 欧美极品在线播放 | 精品视频一区二区三区在线观看 | 精品在线一区二区 | 国产精品视频不卡 | 一区二区三区免费 | 午夜激情影院 | 欧美日韩国产一区二区三区不卡 | 天堂久久一区 | 亚洲精品久久久一区二区三区 | 亚洲成人av | 97精品超碰一区二区三区 |