Android layouts within layouts, with separate classes handling their input?

Posted by Demonofloom on Stack Overflow See other posts from Stack Overflow or by Demonofloom
Published on 2010-12-22T21:57:20Z Indexed on 2010/12/23 4:54 UTC
Read the original article Hit count: 197

Filed under:
|
|

Hey all, I have created a program in Java that uses Jpanels within Jpanels. One example of this is having a side view containing buttons that change the main view when pressed. The main view also has buttons that can be used to alter itself.

I am trying to re-create this on the android. I have my layout set up from an xml, with a side panel containing buttons and the main view.

There is another xml that contains what I want in the main view.

Now I am struggling to get this separate xml to be displayed in the main view and can’t figure out how I would get the class to handle its own input. I don’t want to paste the code into the main.xml as I want to keep things object orientated and each view needs some custom elements such as different textviews.

An example of what I am trying to convert for the android is below:-

//The ViewInt class has its own layout
ViewInt tempView = new ViewInt(i, mFloorNo);
//The viewInt class is then added to the main window.
mainWindowPanel.add(tempView);

This small bit of code would create a view, add it to the main view and then any input in the main window is handled by that class, but at the same time any input not in this main window is handled by another class (probably the root class). Any help is greatly appreciated, thanks.

To clarify: The program has a side panel layout, containing buttons. And a main view layout that is empty. I am trying to set a .xml layout to this main view layout, and have it so that if any buttons are pressed in that main view then a class for that layout will handle it.

© Stack Overflow or respective owner

Related posts about android

Related posts about Xml