I am aware of how to add EditText but not in the onDraw() function.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(new GaugeAnimation((this),10));
EditText input = (EditText) findViewById(R.id.input);
input.setText("hello");
}
The above will not work, also, the below doesn’t work either:
@Override
public void onDraw(Canvas c){
EditText input = (EditText) findViewById(R.id.input);
input.setText("hi");
}
so how can i do this? i would basically like to add an editable text box but because i am not using:
setContentView(new R.layout.main);
its messing up. Any suggestions?
i tried:
public class GaugeAnimation extends View{
public GaugeAnimation(Context context, int value){
EditText input = new EditText(context);
input.setId(R.id.input);
}
}
but it still doesn’t work what am i doing wrong?
When you construct your
GaugeAnimationview, make sure it callssetId(R.id.input)for the EditText view you want to use for input. Then your first method will work.You should be aware that you should not make updates to UI elements from a view’s
onDrawmethod like you tried.