I have a class that extends TextView
, it basically adds some feathers to display text with different colors ,animation etc...
Now I'm working with other custom view that don't uses the Android TextView
but uses a Label
view that not related to TextView
at all .
What I want to do is to copy all the logic and methods to a new class that will extend Label
and just to change some few things: colors are not int type but Color
type and so on. the setText(text)
works the same.
Do I have to really copy-paste all the class and change some stuff or I can somehow use one logic and make some few changes on the new class. When it will extends Label
the setText(text)
will act the same on Label (class Label
have that method too)
public class TextDisplayTextView extends TextView {
public TextDisplayTextView(Context context) {
super(context);
init();
}
public TextDisplayTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void setText (String text) {
// do some effects
setText(txt);
}
private void setTextColor (int color) {
// do some color effects
setTextColor(color);
}
.
.
.
}
The new class - TextDisplayLabel
public class TextDisplayLabelView extends Label {
public TextDisplayLabelView(Label.Design design ) {
super(design);
init();
}
private void setText (String text) {
// do some effects
setText(txt);
}
private void setTextColor (Color color) {
// do some color effects
setLabelColor(color);
}
.
.
.
}
EDITED: I want to use it in two cases
In class that uses TextView
:
TextDisplayTextView textV = (TextDisplayTextView) mLayout.findViewById(R.id.textDisplay);
mText.setText()
In class the uses Label
:
Label.Design designStyle = new Label.Design designStyle();
TextDisplayLabelView textL = new TextDisplayTextView (designStyle);
textL.setText();