vendredi 30 mai 2014

How to pass an integer from an activity to its view


Vote count:

0




I have tried to pass on an int without success from this activity:



public class SecondActivity extends Activity {

private int sign=3;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TestView newView = new TestView(this, sign);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(newView);

}

}


to this view:



public class TestView extends View {

private int sign;

public TestView(Context context, int signValue) {
super(context);
this.sign=signValue;
}
}


But the value isn't passed on, the variable "sign" remains null. Am I missing something? What?


(In my code the variable sign gets its value from a bundle, but I tested it and know it's getting the right value.)



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire