button crashes app/\end activity via menu

Put your problem here if it does not fit any of the other categories.

Re: using logcat to debug?

Postby superferd » Tue May 17, 2011 5:27 pm

Yeah! I got the options menu to work! But still if i keep this snippet:(yes it's different but same issue)
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Button button = (Button)findViewById(R.id.imageButton1);
  2.         button.setOnClickListener(mZoomListener);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


it just crashes on start-up. Is there anyway to make imageButton1 work?

new Start.java:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.ferdix.wham;
  2.  
  3. import android.app.Activity;
  4. import android.content.ComponentName;
  5. import android.content.Intent;
  6. import android.os.Bundle;
  7. import android.view.Menu;
  8. import android.view.MenuInflater;
  9. import android.view.MenuItem;
  10. import android.view.View;
  11. import android.view.View.OnClickListener;
  12. import android.widget.Button;
  13.  
  14.  
  15.  
  16. public class Start extends Activity {
  17.     @Override
  18.     protected void onCreate(Bundle savedInstanceState) {
  19.         super.onCreate(savedInstanceState);
  20.  
  21.         setContentView(R.layout.main);
  22.  
  23.      //problem      
  24.         Button button = (Button)findViewById(R.id.imageButton1);
  25.         button.setOnClickListener(mZoomListener);
  26.     }
  27.  
  28.  
  29.     private OnClickListener mZoomListener = new OnClickListener() {
  30.         public void onClick(View v) {
  31.             startActivity(new Intent(Start.this, game.class));
  32.             overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
  33.         }
  34.     };
  35.     public boolean onCreateOptionsMenu(Menu menu) {
  36.         MenuInflater inflater = getMenuInflater();
  37.         inflater.inflate(R.menu.menumain, menu);
  38.  
  39.         MenuItem mi_settings = (MenuItem)menu.findItem(R.id.new_game);
  40.         mi_settings.setIntent(new Intent(Start.this, game.class));
  41.         return true;
  42. }}
  43.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
-superferd-please help me
Die? over my dead body!
superferd
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun May 15, 2011 8:23 am

Top

Re: using logcat to debug?/\button crashes app

Postby superferd » Thu May 19, 2011 11:25 am

Please help, I have no idea what the problem is.
-superferd-please help me
Die? over my dead body!
superferd
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun May 15, 2011 8:23 am

Re: button crashes app/\end activity via menu

Postby superferd » Sun May 22, 2011 12:00 am

How do you close an activity via a menu item?
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.     public boolean onCreateOptionsMenu(Menu menu) {
  2.         MenuInflater inflater = getMenuInflater();
  3.         inflater.inflate(R.menu.menumain, menu);
  4.  
  5.         MenuItem newgame = (MenuItem)menu.findItem(R.id.new_game);
  6.         newgame.setIntent(new Intent(Start.this, game.class));
  7.         overridePendingTransition(R.anim.fade, R.anim.hold);
  8.         //something here?
  9.         return true;
  10.         }
  11.     };
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


I have 2 items in the menu, "new_game" and "close". "new_game" is working but how do i make "close" close the activity?

Please help.
-superferd-please help me
Die? over my dead body!
superferd
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun May 15, 2011 8:23 am

Re: button crashes app/\end activity via menu

Postby superferd » Sat May 28, 2011 11:58 am

I have created a new project just to test buttons and they work but in this app, they just won't please help...
-superferd-please help me
Die? over my dead body!
superferd
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun May 15, 2011 8:23 am

Top
Previous

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 20 guests