6 posts / 0 new
Last post
Thomas Cottin
JaKe's picture
Offline
Joined: 10 Jan 2012
Posts:
Change of page

Hello

On my application I would like to change page. Pass of a homepage (MainScreen) has a Paramètre page (MainPara).

class MainScreen ----->class MainPara

Thanks

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Hi, you need to call the show() method of MainPara.

class MainScreen : public Screen, public ButtonListener
{
  public:
    MainScreen() 
    {
      mPara = new Parametre();
      mButton = new Button();
      mButton->setText("Parametre");
      mButton->addButtonListener(this);
    }

    void buttonClicked(Widget* button)
    {
       mPara->show();
    }
};

 

Thomas Cottin
JaKe's picture
Offline
Joined: 10 Jan 2012
Posts:

I want switch a different page.

I have care of heritage between my classes

I want start my application with Page MainScreen and Click on button "Parametre" to switch page MainPara and Click on button "retour" to switch page MainScreen and Click on button "Connection" switch page MainCap.

I am student and my project is to create an application for an alarm.

and i'm speak very bad english sorry :(

AttachmentSize
Main_cpp.txt 1.28 KB
MainCap_cpp.txt 1.45 KB
Maincap_h.txt 1011 bytes
MainPara_cpp.txt 2.05 KB
MainPara_h.txt 1.08 KB
MainScreen_cpp.txt 3.29 KB
MainScreen_h.txt 1.14 KB
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Sure.  Add MainPara.h MainScreen with #include "MainPara.h" and set a MainPara* called mMainPara;

/*
 * MainScreen.h
 *
 *  Created on: 23 janv. 2012
 *      Author: profiris
 */

#ifndef MAINSCREEN_H_
#define MAINSCREEN_H_
#include <maapi.h>
#include <MAUtil/util.h>
#include <ma.h> 				// Syscalls
#include <MAUtil/String.h>		// C++ String class
#include <MAUtil/Moblet.h>		// Moblet class
#include <conprint.h>			// lprintfln for logging
#include <NativeUI/Image.h>
#include <NativeUI/Widgets.h>	// Include all widgets
#include "MAHeaders.h"
#include "NativeUIMoblet.h"

#include "MainPara.h"


using namespace MAUtil;
using namespace NativeUI;

class MainScreen :
	public Screen,
	public ButtonListener,
	public EditBoxListener
{
	public:
		MainScreen();
		~MainScreen();
		void clearButtonClicked();
		void submitEditBoxContent();
		virtual void buttonClicked(Widget* button);
		virtual void editBoxReturn(EditBox* editBox);
	private:
		void createUI();

	private:
		VerticalLayout* mMainLayout;
		Label* mInstructionsLogin;
		Label* mInstructionsPwd;
		Label* mInstructionsOk;
		EditBox* mLoginBox;
		EditBox* mPasswordBox;
		Button* mParametreButton;
		Button* mLoginButton;
		Image* mImage;

		MainPara* mMainPara;
};



#endif /* MAINSCREEN_H_ */

Then in MainScreen.cpp

MainScreen::MainScreen():
	Screen(),mImage(NULL), mMainPara(NULL)
	{
		createUI();
		mParametreButton->addButtonListener(this);
		mLoginButton->addButtonListener(this);
		mPasswordBox->addEditBoxListener(this);
	}
	MainScreen::~MainScreen()
	{
		mParametreButton->removeButtonListener(this);
		mLoginButton->removeButtonListener(this);
		mPasswordBox->removeEditBoxListener(this);
		
		if(mMainPara != NULL) delete mMainPara;
	}


    void MainScreen::buttonClicked(Widget* button)
    {
        if(mMainPara == NULL)
            mMainPara = new MainPara();

        mMainPara->show();
    }

 

Thomas Cottin
JaKe's picture
Offline
Joined: 10 Jan 2012
Posts:

When I modify as you made him he puts me the following error:

C:\Documents and Settings\cottin\WorkSpace\HouseAlert\/MainScreen.h:51: error: ISO C++ forbids declaration of `MainPara' with no type
C:\Documents and Settings\cottin\WorkSpace\HouseAlert\/MainScreen.h:51: error: expected `;' before '*' token

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Did you include this line?
#include "MainPara.h"