我正在钻研Layouts&试图了解它们的工作原理。布局是否与Java Swing中的JPanel类似?也就是说,我们在哪里声明一个主面板&将所有小部件添加到其中?
我不明白的一件事是,当我们创建移动应用时,我们会创建一个布局&列表框。这两个对象之间有什么关系?
PS:通过下面的实验,我的小工具没有显示出来?它只是一个空白的黑屏。为什么会这样?
#include <MAUtil/Moblet.h>
#include <MAUI/Layout.h>
#include <MAUI/ListBox.h>
#include <MAUI/Label.h>
#include <MAUI/EditBox.h>
#include <MAUI/Screen.h>
#include <MAUtil/Environment.h>
#include <madmath.h>
#include <conprint.h>
using namespace MAUtil;
using namespace MAUI;
class TemperatureScreen : public Screen //, public PointerListener
{
public:
TemperatureScreen()
{
MAExtent screenDim = maGetScrSize();
Layout* mainLayout = new Layout( 0, 0, EXTENT_X(screenDim), EXTENT_Y(screenDim), NULL, 1, 3 );
ListBox* mainListBox = new ListBox( 0, 0, 100, 200, mainLayout,
ListBox::LBO_VERTICAL, ListBox::LBA_LINEAR,
true );
mainListBox -> setPaddingLeft( 10 );
mainListBox -> setPaddingRight( 10 );
mainListBox -> setPaddingTop( 10 );
mainListBox -> setPaddingBottom( 10 );
mainListBox -> setBackgroundColor( 900 );
mainLayout -> setBackgroundColor( 300 );
Label *celLabel = new Label( 10, 300, 50, 20, mainLayout );
Label *fahLabel = new Label( 10, 300, 50, 20, mainLayout );
EditBox *celEdit = new EditBox( 10, 300, 50, 20, mainLayout );
EditBox *fahEdit = new EditBox( 10, 300, 50, 20, mainLayout );
Label *toCelsiusRb = new Label( 10, 300, 50, 20, mainLayout );
Label *toFahRb = new Label( 10, 300, 50, 20, mainLayout );
Label *convertLabel = new Label( 10, 300, 50, 20, mainLayout );
Label *exitLabel = new Label( 10, 300, 50, 20, mainLayout );
celLabel -> setCaption( "Celcius" );
fahLabel -> setCaption( "Fahrenheit" );
convertLabel -> setCaption( "Convert" );
exitLabel -> setCaption( "Exit" );
/*celLabel -> addPointerListener( this );
fahLabel -> addPointerListener( this );
convertLabel -> addPointerListener( this );
exitLabel -> addPointerListener( this );*/
mainLayout -> add( celLabel );
mainLayout -> add( fahLabel );
mainLayout -> add( convertLabel );
mainLayout -> add( exitLabel );
}
};
class TemperatureMoblet : public Moblet
{
public:
TemperatureMoblet()
{
instance = new TemperatureScreen();
instance -> show();
}
~TemperatureMoblet()
{
delete instance;
}
void keyPressEvent(int keyCode, int nativeCode)
{
// todo: handle key presses
printf( "Blah" );
}
void keyReleaseEvent(int keyCode, int nativeCode)
{
// todo: handle key releases
}
private:
TemperatureScreen *instance;
};
extern "C" int MAMain()
{
Moblet::run(new TemperatureMoblet());
return 0;
};
答案 0 :(得分:0)
尝试将maUpdateScreen()放入计时器事件或键监听器中,只是为了看看会发生什么。
如果您需要更多帮助,请回复我。
您可以在以下位置尝试使用新版本的mosync:
http://www.mosync.com/documentation/manualpages/whats-new-mosync-26-pyramid
/托尼