Answer the question
In order to leave comments, you need to log in
How to properly extend Android widget classes? How does this affect the XML layout?
I was not satisfied with the standard functionality of the Button widget and I decided to add one field to it:
package com.some.thing;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.Button;
public class ButtonVar extends Button{
protected boolean correct = false;
ButtonVar (Context context){
super(context);
}
ButtonVar (Context context, AttributeSet attrs){
super(context, attrs);
}
ButtonVar (Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
}
public void setCorrect (boolean correct){
this.correct = correct;
}
public boolean getCorrect (){
return this.correct;
}
}
<com.some.thing.ButtonVar
android:id="@+id/buttonVar1"
style="@style/ButtonVars"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:text="@string/button_var1_default"
/>
<com.some.thing.ButtonVar
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question