Opening up a new activity from a button + other questions

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

39 Replies - 6599 Views - Last Post: 02 May 2012 - 06:32 AM

#1 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Opening up a new activity from a button + other questions

Posted 19 April 2012 - 11:23 PM

Hi, I'm trying to make a new activity open up when a button is clicked using this code but it isn't working. Can anyone check my code out and tell what I'm doing wrong?

New Activity
package edu.isaacfinal;

import android.app.Activity; 
import android.content.Intent;
import android.os.Bundle;

public class AboutActivity extends Activity
{
	@Override 
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.about);
		Thread timer = new Thread()
		{
			public void run()
			{
				try
				{
				     sleep(5000); 
				}catch(InterruptedException e)
				{
				     e.printStackTrace(); 
				}finally{
					 Intent openStartingPoint = new Intent("edu.isaacfinal.STARTINGPOINT");
				     startActivity(openStartingPoint); 
				}
			}
		};
		timer.start(); 
	}
}



Main program
package edu.isaacfinal;

import java.util.ArrayList;
import java.util.Collections;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
//import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

	public class AndroidFinal extends Activity 
	{
		private static final String TAG = "Midterm";
		private static final int DIALOG_QUIT_ID = 0;
		private static final int NEXT_BUTTON = 1;
		private static final int SHOW_BUTTON = 2;
		private static final int GUESS_BUTTON = 3;
		private static final int DEFINE_BUTTON = 4;
		private static final int ABOUT_BUTTON = 5; 
		private static final int QUIT_BUTTON = 6;
		//private static final int BACK_BUTTON = 7; 
		
	    private String[] terms;
	    private String[] definitions;
	    private int termsUsed;
	    ArrayList<Word> words;
	    
	    private MediaPlayer rightMediaPlayer;
		private MediaPlayer wrongMediaPlayer;
	    
	    private Button nextButton;
	    private Button showButton;
	    private Button guessButton;
	    private Button defineButton;
	    private Button aboutButton;
	    private Button quitButton;
	    //private Button backButton;
	    private TextView termArea;
	    private TextView definitionArea;
	    private EditText guessText;

	    
		/** Called when the activity is first created. */
	    @Override
	    public void onCreate(Bundle savedInstanceState) 
	    {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.main);
	        
	        Log.v( TAG, "Starting up the project ..." );
	        
	        
	        // read the data from the XML
	        Resources res = getResources();
	        terms = res.getStringArray( R.array.terms );
	        definitions = res.getStringArray( R.array.definitions );
	        
	        // Just checking that the 2 arrays match
	        Log.v( TAG, "terms-length" + terms.length );
	        Log.v( TAG, "definitions-length" + definitions.length );
	        
	        // load up the ArrayList of Words
	        words = new ArrayList<Word>( terms.length );
	        for ( int i = 0; i < terms.length; i++ )
	        {
	        	words.add( new Word( terms[i], definitions[i] ) );
	        }
	      
	        // get the objects for the UI widgets
	        nextButton = (Button) findViewById( R.id.next );
	        showButton = (Button) findViewById( R.id.show );
	        guessButton = (Button) findViewById( R.id.guess );
	        defineButton = (Button) findViewById( R.id.define );
	        
	        aboutButton = (Button) findViewById(R.id.about);

	        quitButton = (Button) findViewById(R.id.quit);
	        //backButton = (Button) findViewById(R.id.backtogame);
	        termArea = (TextView) findViewById( R.id.term_area );
	        definitionArea = (TextView) findViewById( R.id.definition_area );
	        guessText = (EditText) findViewById( R.id.guess_text );
	      
	        // set up the button click listeners for each button (by ID)
	        nextButton.setonclickListener( new ButtonclickListener( NEXT_BUTTON ) );
	        showButton.setonclickListener( new ButtonclickListener( SHOW_BUTTON ) );
	        guessButton.setonclickListener( new ButtonclickListener( GUESS_BUTTON ) );
	        defineButton.setonclickListener( new ButtonclickListener( DEFINE_BUTTON ) );
	        aboutButton.setonclickListener(new ButtonclickListener(ABOUT_BUTTON)); 
	        
	        
	        quitButton.setonclickListener(new ButtonclickListener(QUIT_BUTTON));
	       // backButton.setonclickListener(new ButtonclickListener(BACK_BUTTON));
	        
	        // set up the sound effects
	        rightMediaPlayer = MediaPlayer.create(  getApplicationContext(), R.raw.zoop );
	    	wrongMediaPlayer = MediaPlayer.create(  getApplicationContext(), R.raw.screech );
	        
	    	// initialize the variables
	        clearUsed();
	        
	        // and start with a word
	        newWord();
	        	        
	    }
	    
	    /*
	     * termsUsed keeps track of when the whole set of words has been used
	     * This methods starts it over and shuffles the words anew
	     */
	    public void clearUsed()
	    {
	    	termsUsed = 0;
	    	
	    	Collections.shuffle( words );
	    }
	    
	    /*
	     * Set up a new word: clear the guess and definition area and
	     * get the scrambled word and show it in red text.
	     */
	    private void newWord()
	    {
	    	definitionArea.setText( "" );
			guessText.setText( "" );
			
			termArea.setText( words.get(termsUsed).getScrambledWord() );
			termArea.setTextColor( Color.RED );
			
	    }
	    
	    
	    /*
	     * Show the unscrambled word in green and its definition
	     */
	    private void unscrambleWord()
	    {
	    	termArea.setText( words.get(termsUsed).getWord() );
	    	termArea.setTextColor( Color.GREEN );
	    	
			definitionArea.setText( words.get(termsUsed).getDefinition() );
		
	    }
	    
	    /*private void aboutDetails()
	    {

	            Button next = (Button) findViewById(R.id.about);
	            next.setonclickListener(new View.onclickListener() {
	                public void onclick(View view) {
	                    Intent myIntent = new Intent(view.getContext(), AboutActivity.class);
	                    startActivityForResult(myIntent, 0);
	                }

	            });
	    }*/
	    
	    /*
	    ** This method is called when the dialogs are first shown (showDialog)
	    ** We only have a quit dialog
	    */
	    @Override
	    protected Dialog onCreateDialog( int id )
	    {
	    	Dialog dialog = null;
	    	
	    	// all these dialogs can be built using the AlertDialog builder
	    	// only the about dialog is described in xml, the other 2 are built
	    	// directly in the code.  AlertDialog has some set styles and button
	    	// options - look them up.
	    	AlertDialog.Builder builder = new AlertDialog.Builder( this );
	    	
	    	switch( id )
	    	{
	    		case DIALOG_QUIT_ID:
	    			// the simplest dialog style just has a message and 2 buttons
	    			builder.setMessage( R.string.quit_question );
	    			builder.setCancelable( false );
	    			builder.setPositiveButton( R.string.yes,
	    				new DialogInterface.onclickListener() 
	    				{
	    					// set what to do if the user says -yes- to quitting
	    					public void onclick( DialogInterface dialog, int id )
	    					{
	    						AndroidFinal.this.finish();
	    					}
	    				}
	    			);
	    			builder.setNegativeButton( R.string.no, null );
	    			dialog = builder.create();
	    			
	    			break;
	    							
	    	}
	    	return dialog;
	    	
	    }
	    
	    
	    /*
	     * A method of activity for creating the Options Menu the first time
	     * @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
	     */
	    @Override
	    public boolean onCreateOptionsMenu( Menu menu )
	    {
	    	super.onCreateOptionsMenu(menu);
	    	
	    	// use the inflater to build from the XML
	    	MenuInflater inflater = getMenuInflater();
	    	inflater.inflate(  R.menu.options_menu, menu);
	    	return true;
	    }
	    
	    
	    /*
	     * A method of Activity for handling the Options Menu - ie the main app menu
	     * @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
	     */
	    @Override
	    public boolean onOptionsItemSelected( MenuItem item )
	    {
	    	// This is automatically called when a menu option is selected - take the right action
	    	switch( item.getItemId() )
	    	{	
	    		case R.id.quit:
	    			showDialog( DIALOG_QUIT_ID );
	    			break;	
	    	}
	    	
	    	return true;
	    	
	    }
	   
	    
	    @Override
	    protected void onresume()
	    {
	    	super.onresume();
	    	
	    	rightMediaPlayer = MediaPlayer.create(  getApplicationContext(), R.raw.zoop );
	    	wrongMediaPlayer = MediaPlayer.create(  getApplicationContext(), R.raw.screech );
	    	
	    }
	    
	    @Override
	    protected void onpause()
	    {
	    	super.onpause();
	    	
	    	rightMediaPlayer.release();
	    	wrongMediaPlayer.release();
	    	
	    }
	  
	    
	    public class ButtonclickListener implements View.onclickListener
	    {
	    	int button_id;
	    	
	    	public ButtonclickListener( int id )
	    	{
	    		// Tell which button you are in the beginning
	    		this.button_id = id;
	    	}
	    	
	    	public void onclick( View view )
	    	{
	    		// Then we know which button you are every time
	    		// termsUsed is counting and keeping track of which word we are on
	    		switch ( button_id )
	    		{
	    			case DEFINE_BUTTON:
	    				// Display the definition of the current word
	    				definitionArea.setText( words.get(termsUsed).getDefinition() );
	    				break;
	    			
	    		
	    			case SHOW_BUTTON:
	    				// Display the unscrambled current word
	    				// why not show the definition too?
	    				unscrambleWord();
	       				break;
	    				
	    			case GUESS_BUTTON:
	    				// if the word is correct show it, otherwise beep
	    				String guess = ( (TextView) guessText).getText().toString();
	    				if ( words.get( termsUsed ).getWord().equals(  guess  ) )
	    				{
	    					rightMediaPlayer.start();
	    					unscrambleWord();
	    				}
	    				else
	    				{
	    					wrongMediaPlayer.start();
	    				}
	    				break;
	    				
	    			case NEXT_BUTTON:
	    				//  Move to the next word
	    				termsUsed++;
	    				
	    				//  Rescramble the word list if we've reached the end of it
	    				if ( termsUsed == terms.length )
	    	    			clearUsed();
	    	    		
	    				// show the next word and clear the other fields
	    	    		newWord();

	    				break;
	    		    
	    			case ABOUT_BUTTON:
	    				
	    			case QUIT_BUTTON:
	    				finish();
	    				
	    			default:
	    				break;
	    		        }
	    		
	    		
	    		        {
	    	
	    
	    }    
}}}




Is This A Good Question/Topic? 0
  • +

Replies To: Opening up a new activity from a button + other questions

#2 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 849
  • View blog
  • Posts: 2,585
  • Joined: 29-July 11

Re: Opening up a new activity from a button + other questions

Posted 20 April 2012 - 09:09 AM

What is edu.isaacfinal.STARTINGPOINT?

Intent i = new Intent(getApplicationContext(), OtherClass.class);
startActivity(i);



is how you start another class.
Was This Post Helpful? 0
  • +
  • -

#3 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Opening up a new activity from a button + other questions

Posted 20 April 2012 - 09:50 AM

View Postfarrell2k, on 20 April 2012 - 10:09 AM, said:

What is edu.isaacfinal.STARTINGPOINT?

Intent i = new Intent(getApplicationContext(), OtherClass.class);
startActivity(i);



is how you start another class.



so should "OtherClass.class" be "AboutActivity.class" since this is the name of the new activity I'm trying to open?
Was This Post Helpful? 0
  • +
  • -

#4 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Opening up a new activity from a button + other questions

Posted 21 April 2012 - 03:59 AM

Yes. :)
Was This Post Helpful? 0
  • +
  • -

#5 htc(hot-taco-cheese)  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 17
  • View blog
  • Posts: 71
  • Joined: 04-December 10

Re: Opening up a new activity from a button + other questions

Posted 22 April 2012 - 06:32 PM

Make sure you list all of your Activities in your AndroidManifest.xml. If you don't, you will get some force closes.
Was This Post Helpful? 0
  • +
  • -

#6 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Opening up a new activity from a button + other questions

Posted 22 April 2012 - 07:02 PM

Just made some changes to my code but now it's crashing. The parts in bold are the changes I've added.

AboutActivity.java
package edu.isaacfinal;

import android.app.Activity; 
import android.os.Bundle;

public class AboutActivity extends Activity
{
	@Override 
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.about);
	}
}

AndroidFinal.java
package edu.isaacfinal;

import java.util.ArrayList;
import java.util.Collections;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
//import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.onclickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

	public class AndroidFinal extends Activity 
	{
		private static final String TAG = "Midterm";
		private static final int DIALOG_QUIT_ID = 0;
		private static final int NEXT_BUTTON = 1;
		private static final int SHOW_BUTTON = 2;
		private static final int GUESS_BUTTON = 3;
		private static final int DEFINE_BUTTON = 4;
		private static final int ABOUT_BUTTON = 5; 
		private static final int QUIT_BUTTON = 6;
		//private static final int BACK_BUTTON = 7; 
		
	    private String[] terms;
	    private String[] definitions;
	    private int termsUsed;
	    ArrayList<Word> words;
	    
	    private MediaPlayer rightMediaPlayer;
		private MediaPlayer wrongMediaPlayer;
	    
	    private Button nextButton;
	    private Button showButton;
	    private Button guessButton;
	    private Button defineButton;
	    private Button aboutButton;
	    private Button quitButton;
	    //private Button backButton;
	    private TextView termArea;
	    private TextView definitionArea;
	    private EditText guessText;

	    
		/** Called when the activity is first created. */
	    @Override
	    public void onCreate(Bundle savedInstanceState) 
	    {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.main);
	        
	        Log.v( TAG, "Starting up the project ..." );
	        
	        
	        // read the data from the XML
	        Resources res = getResources();
	        terms = res.getStringArray( R.array.terms );
	        definitions = res.getStringArray( R.array.definitions );
	        
	        // Just checking that the 2 arrays match
	        Log.v( TAG, "terms-length" + terms.length );
	        Log.v( TAG, "definitions-length" + definitions.length );
	        
	        // load up the ArrayList of Words
	        words = new ArrayList<Word>( terms.length );
	        for ( int i = 0; i < terms.length; i++ )
	        {
	        	words.add( new Word( terms[i], definitions[i] ) );
	        }
	      
	        // get the objects for the UI widgets
	        nextButton = (Button) findViewById( R.id.next );
	        showButton = (Button) findViewById( R.id.show );
	        guessButton = (Button) findViewById( R.id.guess );
	        defineButton = (Button) findViewById( R.id.define );
	        
	      [b]  Button about = (Button) findViewById(R.id.about);
                about.setonclickListener(new onclickListener()
            {
            	public void onclick(View v)
            	{
            		Intent intent = new Intent(v.getContext(), AboutActivity.class);
            		startActivityForResult(intent, 0);
            	}
            });[/b]
	        quitButton = (Button) findViewById(R.id.quit);
	        //backButton = (Button) findViewById(R.id.backtogame);
	        termArea = (TextView) findViewById( R.id.term_area );
	        definitionArea = (TextView) findViewById( R.id.definition_area );
	        guessText = (EditText) findViewById( R.id.guess_text );
	      
	        // set up the button click listeners for each button (by ID)
	        nextButton.setonclickListener( new ButtonclickListener( NEXT_BUTTON ) );
	        showButton.setonclickListener( new ButtonclickListener( SHOW_BUTTON ) );
	        guessButton.setonclickListener( new ButtonclickListener( GUESS_BUTTON ) );
	        defineButton.setonclickListener( new ButtonclickListener( DEFINE_BUTTON ) );
	        aboutButton.setonclickListener(new ButtonclickListener(ABOUT_BUTTON)); 
	        
	        
	        quitButton.setonclickListener(new ButtonclickListener(QUIT_BUTTON));
	       // backButton.setonclickListener(new ButtonclickListener(BACK_BUTTON));
	        
	        // set up the sound effects
	        rightMediaPlayer = MediaPlayer.create(  getApplicationContext(), R.raw.zoop );
	    	wrongMediaPlayer = MediaPlayer.create(  getApplicationContext(), R.raw.screech );
	        
	    	// initialize the variables
	        clearUsed();
	        
	        // and start with a word
	        newWord();
	        	        
	    }
	    
	    /*
	     * termsUsed keeps track of when the whole set of words has been used
	     * This methods starts it over and shuffles the words anew
	     */
	    public void clearUsed()
	    {
	    	termsUsed = 0;
	    	
	    	Collections.shuffle( words );
	    }
	    
	    /*
	     * Set up a new word: clear the guess and definition area and
	     * get the scrambled word and show it in red text.
	     */
	    private void newWord()
	    {
	    	definitionArea.setText( "" );
			guessText.setText( "" );
			
			termArea.setText( words.get(termsUsed).getScrambledWord() );
			termArea.setTextColor( Color.RED );
			
	    }
	    
	    
	    /*
	     * Show the unscrambled word in green and its definition
	     */
	    private void unscrambleWord()
	    {
	    	termArea.setText( words.get(termsUsed).getWord() );
	    	termArea.setTextColor( Color.GREEN );
	    	
			definitionArea.setText( words.get(termsUsed).getDefinition() );
		
	    }
	    
	    /*private void aboutDetails()
	    {

	            Button next = (Button) findViewById(R.id.about);
	            next.setonclickListener(new View.onclickListener() {
	                public void onclick(View view) {
	                    Intent myIntent = new Intent(view.getContext(), AboutActivity.class);
	                    startActivityForResult(myIntent, 0);
	                }

	            });
	    }*/
	    
	    /*
	    ** This method is called when the dialogs are first shown (showDialog)
	    ** We only have a quit dialog
	    */
	    @Override
	    protected Dialog onCreateDialog( int id )
	    {
	    	Dialog dialog = null;
	    	
	    	// all these dialogs can be built using the AlertDialog builder
	    	// only the about dialog is described in xml, the other 2 are built
	    	// directly in the code.  AlertDialog has some set styles and button
	    	// options - look them up.
	    	AlertDialog.Builder builder = new AlertDialog.Builder( this );
	    	
	    	switch( id )
	    	{
	    		case DIALOG_QUIT_ID:
	    			// the simplest dialog style just has a message and 2 buttons
	    			builder.setMessage( R.string.quit_question );
	    			builder.setCancelable( false );
	    			builder.setPositiveButton( R.string.yes,
	    				new DialogInterface.onclickListener() 
	    				{
	    					// set what to do if the user says -yes- to quitting
	    					public void onclick( DialogInterface dialog, int id )
	    					{
	    						AndroidFinal.this.finish();
	    					}
	    				}
	    			);
	    			builder.setNegativeButton( R.string.no, null );
	    			dialog = builder.create();
	    			
	    			break;
	    							
	    	}
	    	return dialog;
	    	
	    }
	    
	    
	    /*
	     * A method of activity for creating the Options Menu the first time
	     * @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
	     */
	    @Override
	    public boolean onCreateOptionsMenu( Menu menu )
	    {
	    	super.onCreateOptionsMenu(menu);
	    	
	    	// use the inflater to build from the XML
	    	MenuInflater inflater = getMenuInflater();
	    	inflater.inflate(  R.menu.options_menu, menu);
	    	return true;
	    }
	    
	    
	    /*
	     * A method of Activity for handling the Options Menu - ie the main app menu
	     * @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
	     */
	    @Override
	    public boolean onOptionsItemSelected( MenuItem item )
	    {
	    	// This is automatically called when a menu option is selected - take the right action
	    	switch( item.getItemId() )
	    	{	
	    		case R.id.quit:
	    			showDialog( DIALOG_QUIT_ID );
	    			break;	
	    	}
	    	
	    	return true;
	    	
	    }
	   
	    
	    @Override
	    protected void onresume()
	    {
	    	super.onresume();
	    	
	    	rightMediaPlayer = MediaPlayer.create(  getApplicationContext(), R.raw.zoop );
	    	wrongMediaPlayer = MediaPlayer.create(  getApplicationContext(), R.raw.screech );
	    	
	    }
	    
	    @Override
	    protected void onpause()
	    {
	    	super.onpause();
	    	
	    	rightMediaPlayer.release();
	    	wrongMediaPlayer.release();
	    	
	    }
	  
	    
	    public class ButtonclickListener implements View.onclickListener
	    {
	    	int button_id;
	    	
	    	public ButtonclickListener( int id )
	    	{
	    		// Tell which button you are in the beginning
	    		this.button_id = id;
	    	}
	    	
	    	public void onclick( View view )
	    	{
	    		// Then we know which button you are every time
	    		// termsUsed is counting and keeping track of which word we are on
	    		switch ( button_id )
	    		{
	    			case DEFINE_BUTTON:
	    				// Display the definition of the current word
	    				definitionArea.setText( words.get(termsUsed).getDefinition() );
	    				break;
	    			
	    		
	    			case SHOW_BUTTON:
	    				// Display the unscrambled current word
	    				// why not show the definition too?
	    				unscrambleWord();
	       				break;
	    				
	    			case GUESS_BUTTON:
	    				// if the word is correct show it, otherwise beep
	    				String guess = ( (TextView) guessText).getText().toString();
	    				if ( words.get( termsUsed ).getWord().equals(  guess  ) )
	    				{
	    					rightMediaPlayer.start();
	    					unscrambleWord();
	    				}
	    				else
	    				{
	    					wrongMediaPlayer.start();
	    				}
	    				break;
	    				
	    			case NEXT_BUTTON:
	    				//  Move to the next word
	    				termsUsed++;
	    				
	    				//  Rescramble the word list if we've reached the end of it
	    				if ( termsUsed == terms.length )
	    	    			clearUsed();
	    	    		
	    				// show the next word and clear the other fields
	    	    		newWord();

	    				break;
	    		    
	    			case ABOUT_BUTTON:
	    				
	    			case QUIT_BUTTON:
	    				finish();
	    				
	    			default:
	    				break;
	    		        }
	    		
	    		
	    		        {
	    	
	    
	    }    
}}}



Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="edu.isaacfinal"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />
    
    <application>
    <activity android:name=".AboutActivity" android:label="@string/app_name">
    <intent-filter>
    [b]<action android:name="edu.isaacfinal.AboutActivity.class" />[/b]
    <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    </activity>
    
     
    <activity android:name=".AndroidFinal" android:label="@string/app_name">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
   
    </application>
</manifest>

Was This Post Helpful? 0
  • +
  • -

#7 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Opening up a new activity from a button + other questions

Posted 22 April 2012 - 07:43 PM

No part are bold :P
Was This Post Helpful? 0
  • +
  • -

#8 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Opening up a new activity from a button + other questions

Posted 22 April 2012 - 08:25 PM

I tried to bold some parts of the code but I guess it didn't work. Pretty much the code with
"" wrapped around it are the changes I made.
Was This Post Helpful? 0
  • +
  • -

#9 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Opening up a new activity from a button + other questions

Posted 22 April 2012 - 11:38 PM

Okey, i just look at your code quickly.

But does it run if you remove <action android:name="edu.isaacfinal.AboutActivity.class" />?
Was This Post Helpful? 0
  • +
  • -

#10 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Opening up a new activity from a button + other questions

Posted 23 April 2012 - 07:42 AM

Nope, it doesn't. I get a "Application edu.isaacfinal has stopped unexpectedly. Please try again."
Was This Post Helpful? 0
  • +
  • -

#11 htc(hot-taco-cheese)  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 17
  • View blog
  • Posts: 71
  • Joined: 04-December 10

Re: Opening up a new activity from a button + other questions

Posted 23 April 2012 - 12:07 PM

Sorry if I didn't catch it, but can you post your LogCat?
Was This Post Helpful? 0
  • +
  • -

#12 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Opening up a new activity from a button + other questions

Posted 23 April 2012 - 06:52 PM

Logcat:
04-24 01:41:54.704: ERROR/Zygote(32): setreuid() failed. errno: 2
04-24 01:42:02.375: ERROR/Zygote(32): setreuid() failed. errno: 17
04-24 01:42:03.645: ERROR/BatteryService(58): usbOnlinePath not found
04-24 01:42:03.645: ERROR/BatteryService(58): batteryVoltagePath not found
04-24 01:42:03.645: ERROR/BatteryService(58): batteryTemperaturePath not found
04-24 01:42:03.665: ERROR/SurfaceFlinger(58): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
04-24 01:42:09.695: ERROR/EventHub(58): could not get driver version for /dev/input/mouse0, Not a typewriter
04-24 01:42:09.695: ERROR/EventHub(58): could not get driver version for /dev/input/mice, Not a typewriter


04-24 01:42:09.885: ERROR/System(58): Failure starting core service
04-24 01:42:09.885: ERROR/System(58): java.lang.SecurityException
04-24 01:42:09.885: ERROR/System(58): at android.os.BinderProxy.transact(Native Method)
04-24 01:42:09.885: ERROR/System(58): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
04-24 01:42:09.885: ERROR/System(58): at android.os.ServiceManager.addService(ServiceManager.java:72)
04-24 01:42:09.885: ERROR/System(58): at com.android.server.ServerThread.run(SystemServer.java:184)


04-24 01:42:10.725: ERROR/SoundPool(58): error loading /system/media/audio/ui/Effect_Tick.ogg
04-24 01:42:10.735: ERROR/SoundPool(58): error loading /system/media/audio/ui/KeypressStandard.ogg
04-24 01:42:10.745: ERROR/SoundPool(58): error loading /system/media/audio/ui/KeypressSpacebar.ogg
04-24 01:42:10.755: ERROR/SoundPool(58): error loading /system/media/audio/ui/KeypressDelete.ogg
04-24 01:42:10.765: ERROR/SoundPool(58): error loading /system/media/audio/ui/KeypressReturn.ogg
04-24 01:42:12.335: ERROR/ThrottleService(58): Could not open GPS configuration file /etc/gps.conf
04-24 01:42:13.575: ERROR/logwrapper(148): executing /system/bin/tc failed: No such file or directory
04-24 01:42:13.585: ERROR/logwrapper(149): executing /system/bin/tc failed: No such file or directory
04-24 01:42:13.645: ERROR/logwrapper(150): executing /system/bin/tc failed: No such file or directory

04-24 01:42:25.670: ERROR/HierarchicalStateMachine(58): TetherMaster - unhandledMessage: msg.what=3
04-24 01:42:43.171: ERROR/jdwp(276): Failed sending reply to debugger: Broken pipe
04-24 01:42:43.582: ERROR/AndroidRuntime(276): FATAL EXCEPTION: main
04-24 01:42:43.582: ERROR/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.isaacfinal/edu.isaacfinal.AndroidFinal}: java.lang.NullPointerException
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)

04-24 01:42:43.582: ERROR/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): Caused by: java.lang.NullPointerException
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at edu.isaacfinal.AndroidFinal.onCreate(AndroidFinal.java:110)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-24 01:42:43.582: ERROR/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
Was This Post Helpful? 0
  • +
  • -

#13 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Opening up a new activity from a button + other questions

Posted 23 April 2012 - 10:31 PM

Well, i get error on aboutButton.setonclickListener(new ButtonclickListener(ABOUT_BUTTON)); (Line 110)
And from what i can see, you are not binding the "aboutButton" to a button.
I can only see you binding "about" to a button and assigning a onclickListener to it (Line 90)
Try removing this: aboutButton.setonclickListener(new ButtonclickListener(ABOUT_BUTTON)); at line 110

This post has been edited by EndLessMind: 25 April 2012 - 07:15 AM

Was This Post Helpful? 1
  • +
  • -

#14 izic  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 197
  • Joined: 15-January 09

Re: Opening up a new activity from a button + other questions

Posted 24 April 2012 - 08:47 PM

View PostEndLessMind, on 23 April 2012 - 11:31 PM, said:

Well, i get error on aboutButton.setonclickListener(new ButtonclickListener(ABOUT_BUTTON)); (Line 110)
And from what i can see, you are not binding the aboutButton to a button.
I can only see you binding about to a button and assigning a onclickListener to it (Line 90)
Try removing this: aboutButton.setonclickListener(new ButtonclickListener(ABOUT_BUTTON)); at line 110


It works! Finally lol and thanks alot. Also, my program is a word scrambler so I have an xml file that stores the scrambled words and their definitions. How would I go about reading the words and definitions from a raw resource input file instead through xml? This is the xml file by the way.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="terms">
    	<item>router</item>
    	<item>chromebook</item>
    	<item>m-commerce</item>
    	<item>froyo</item>
    	<item>android</item>
    	<item>transcoding</item>
    	<item>microbrowser</item>
    	<item>macrocell</item>
    	<item>backhaul</item>
    	<item>hotspot</item>
     </string-array>
     <string-array name="definitions">
    	<item>A device that forwards data packets along networks. 
    	It is connected to at least two networks, commonly two LANs or WANs or a LAN and its ISP\'s network. 
    	These items are located at gateways, the places where two or more networks connect.</item>
    	
    	<item>A new category of notebook computers and mobile devices that runs Google\s cloud-based Chrome OS 
    	operating system.  While they lack the processing power and higher-end features of standard laptops, 
    	these items are built primarily for Web surfing and are optimized for this purpose with the Google Chrome 
    	Web browser as well as near instant-on and instant-resume capabilities</item>
    	
    	<item>The term used to describe the growing trend of using networks that interface with wireless devices, 
    	such as laptops, handheld computers or mobile phones to initiate or complete online electronic commerce transactions. </item>
    	
    	<item>The dessert-themed Android codename for the version 2.2 update of the open source Android mobile 
    	operating system. Short for "Frozen Yogurt," it made its debut in August 2010, adding new features like 
    	USB tethering support (for effectively turning a smartphone into a Wi-Fi hotspot), Flash 10.1 support, 
    	voice dialing over Bluetooth, the ability to store apps on external memory cards, significant speed 
    	improvements and an browser update that adds Google Chrome\'s V8 Javascript engine.</item>
    	
    	<item>Google Inc.\'s open and free software stack that includes an operating system, middleware and also key 
    	applications for use on mobile devices, including smartphones. It is an Open Handset Alliance Project.</item>
    	
    	<item>The process of converting a media file or object from one format to another. It is often used to 
    	convert video formats (i.e., Beta to VHS, VHS to QuickTime, QuickTime to MPEG). But it is also used to fit HTML 
    	files and graphics files to the unique constraints of mobile devices and other Web-enabled products. These devices 
    	usually have smaller screen sizes, lower memory, and slower bandwidth rates. In this scenario, it is performed 
    	by a proxy server or device, which receives the requested document or file and uses a specified annotation 
    	to adapt it to the client.</item>
    	
    	<item>It is a type of browser designed to be used on the small screens of  many different types of mobile devices. 
    	It is commonly used on WAP-based phones, which require a gateway to translate Web pages, news feeds, and other 
    	Internet content.</item>
    	
    	<item>It provides the largest area of coverage within a mobile network. The antennas for these can be mounted on 
    	ground-based masts, rooftops or other existing structures and must be positioned at a height that is not obstructed 
    	by terrain or buildings. They provide radio coverage over varying distances depending on the frequency used, the number 
    	of calls made and the physical terrain. </item>
    	
    	<item>(1) In wireless network technology, to transmit voice and data traffic from a cell site to a switch, i.e., from 
    	a remote site to a central site.  (2) In satellite technology, to transmit data to a point from which it can be uplinked 
    	to a satellite.  (3) To transmit data to a network backbone.</item>
    	
    	<item>A specific geographic location in which an access point provides public wireless broadband network services to 
    	mobile visitors through a WLAN. These are often located in heavily populated places such as airports, train stations, 
    	libraries, marinas, conventions centers and hotels. They typically have a short range of access.</item>
     </string-array>	
</resources>

Was This Post Helpful? 0
  • +
  • -

#15 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: Opening up a new activity from a button + other questions

Posted 25 April 2012 - 07:14 AM

Glad i could help :)
Please don't forget to vote post if they where helpful.

About your other question, i'm not sure what you mean.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3