• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.example.android.apis.text;
18 
19 import android.widget.TextView;
20 import android.content.Context;
21 import android.text.method.ScrollingMovementMethod;
22 import android.text.method.MovementMethod;
23 import android.text.method.KeyListener;
24 import android.text.method.TransformationMethod;
25 import android.text.Editable;
26 import android.util.AttributeSet;
27 
28 import java.util.Map;
29 
30 /**
31  * This is a TextView that is Editable and by default scrollable,
32  * like EditText without a cursor.
33  *
34  * <p>
35  * <b>XML attributes</b>
36  * <p>
37  * See
38  * {@link android.R.styleable#TextView TextView Attributes},
39  * {@link android.R.styleable#View View Attributes}
40  */
41 public class LogTextBox extends TextView {
LogTextBox(Context context)42     public LogTextBox(Context context) {
43         this(context, null);
44     }
45 
LogTextBox(Context context, AttributeSet attrs)46     public LogTextBox(Context context, AttributeSet attrs) {
47         this(context, attrs, android.R.attr.textViewStyle);
48     }
49 
LogTextBox(Context context, AttributeSet attrs, int defStyle)50     public LogTextBox(Context context, AttributeSet attrs, int defStyle) {
51         super(context, attrs, defStyle);
52     }
53 
54     @Override
getDefaultMovementMethod()55     protected MovementMethod getDefaultMovementMethod() {
56         return ScrollingMovementMethod.getInstance();
57     }
58 
59     @Override
getText()60     public Editable getText() {
61         return (Editable) super.getText();
62     }
63 
64     @Override
setText(CharSequence text, BufferType type)65     public void setText(CharSequence text, BufferType type) {
66         super.setText(text, BufferType.EDITABLE);
67     }
68 }
69