Android : Android draw out of a class on an activity

on Friday, October 24, 2014


Good Morning,


I just started my first android project (but have knowledge in Java, VB, etc).


I'm searching all day long bt untl know I was unable to find an answer to my problem, I find a lot of ways to draw on an empty screen ... But I searching a methode to draw multiple diagramms and so on directly on my MainActivity next to my buttons and other controls. In Java I would have used different drawPanels to get the job down but due to missing swing library I can't proceed that way. Are their good tutorials out there on that topic or do you have an advice? I'm glad for every tipp.


Dwon there / you will find an example of my current try, but as said it will just draw the "BAttery" and not the activity components:



public class MainActivity extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


DrawBattery draw = new DrawBattery(this, 96);
setContentView(draw);
}


-



public class DrawBattery extends View {


private int batteryCharge = 0; //battery charge in %

public DrawBattery(Context pContext, int pBatteryCharge)
{
super(pContext);
batteryCharge = pBatteryCharge;
}

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);


...

0 comments:

Post a Comment