Tuesday, February 25, 2014

'Menu / Xml' is not open


Today, the aircraft is doing in the picture to be displayed on the screen, so that the picture through the event listener action occurs

An aircraft category
public class PlaneView extends View {

public float currentX;
public float currentY;
Bitmap plane;
public PlaneView (Context context) {
super (context);
/ / TODO Auto-generated constructor stub
plane = BitmapFactory.decodeResource (context.getResources (), R.drawable.plane);
setFocusable (true);
}
public void onDraw (Canvas canvas)
{
super.onDraw (canvas);
Paint p = new Paint ();
canvas.drawBitmap (plane, currentX, currentY, p);
}
}

mainActivity in

public class MainActivity extends Activity {

private int speed = 10;
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);

requestWindowFeature (Window.FEATURE_NO_TITLE);
getWindow (). setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

final PlaneView planeView = new PlaneView (this);
setContentView (planeView);
planeView.setBackgroundResource (R.drawable.red_title);

WindowManager windowManager = getWindowManager ();
Display display = windowManager.getDefaultDisplay ();
DisplayMetrics metrics = new DisplayMetrics ();

display.getMetrics (metrics);
planeView.currentX = metrics.widthPixels / 2;
planeView.currentY = metrics.heightPixels-40;

planeView.setOnKeyListener (new OnKeyListener ()
{

@ Override
public boolean onKey (View v, int keyCode, KeyEvent event) {
/ / TODO Auto-generated method stub
switch (event.getKeyCode ())
{
case KeyEvent.KEYCODE_S:
planeView.currentY + = speed;
break;
case KeyEvent.KEYCODE_W:
planeView.currentY - = speed;
break;
case KeyEvent.KEYCODE_A:
planeView.currentX - = speed;
break;
case KeyEvent.KEYCODE_D:
planeView.currentX + = speed;
break;
}
planeView.invalidate ();
return true;
}

});
}

@ Override
public boolean onCreateOptionsMenu (Menu menu) {
/ / Inflate the menu; this adds items to the action bar if it is present
.getMenuInflater () inflate (R.menu.main, menu);.
return true;
}



There's two pictures are of my own drawable added to it mdpi picture.

Compile error, then run-time error:

main.xml file I moved in, and then say what menu.xml file error. . I am a novice very depressed.
And give reasons for seeking guidance error method. Thank you cough<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
menu.xml modified not save? Try to save what
Reply:
@ Tantahe
Menu.xml file is not found, ah, my menu folder in the file is main.xml. I saved a lot of times, but did not move this file
Reply:
clean later compiled, try
Reply:
I did not understand this question. . . Found either behind or off to create a new engineering projects, delete projects. Will this prompt. In my case ecplise forced to close. . . Re-opened after the discovery of no problem. . . .

No comments:

Post a Comment