• 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.Editable;
24 import android.util.AttributeSet;
25 
26 /**
27  * This is a TextView that is Editable and by default scrollable,
28  * like EditText without a cursor.
29  *
30  * <p>
31  * <b>XML attributes</b>
32  * <p>
33  * See
34  * {@link android.R.styleable#TextView TextView Attributes},
35  * {@link android.R.styleable#View View Attributes}
36  */
37 public class LogTextBox extends TextView {
LogTextBox(Context context)38     public LogTextBox(Context context) {
39         this(context, null);
40     }
41 
LogTextBox(Context context, AttributeSet attrs)42     public LogTextBox(Context context, AttributeSet attrs) {
43         this(context, attrs, android.R.attr.textViewStyle);
44     }
45 
LogTextBox(Context context, AttributeSet attrs, int defStyle)46     public LogTextBox(Context context, AttributeSet attrs, int defStyle) {
47         super(context, attrs, defStyle);
48     }
49 
50     @Override
getDefaultMovementMethod()51     protected MovementMethod getDefaultMovementMethod() {
52         return ScrollingMovementMethod.getInstance();
53     }
54 
55     @Override
getText()56     public Editable getText() {
57         return (Editable) super.getText();
58     }
59 
60     @Override
setText(CharSequence text, BufferType type)61     public void setText(CharSequence text, BufferType type) {
62         super.setText(text, BufferType.EDITABLE);
63     }
64 }
65