I want to create a custom action bar in my app like the Play Store Action bar so I can have some Back to Home and Search buttons. I'm beginner to Android development and don't know how can I do it.
How can I add these buttons and have this action bar remain in all activity layouts?
Also, how can I create a class that universally handles searches and click events from this action bar without hardcoding in each activity?
I found a solution for my problem.
for creating action bar , my solution is creating a layout and disable native action bar in style.xml by this tag
<item name="android:windowNoTitle">true</item>
then use your own layout instead of native layout.
for handle action bar universaly in all activities instead of writing repetitious codes it's better to create a base class that extends from Activity class and use this class as parent class of other activities instead of using Activity as parent. then write methods in parent class for handle action bar like click event and etc...
Best Regards
Ali
Related
I searched on the forum and I don't find a solution for my issue. So I hope you can help me :)
I work on a personal project for SFC designing (Sequential functional chart) and I'm working with visual studio in SDI(I'm using MFC library). If you see the "design" of an SFC you can see the different elements needed to compose this. So you can find Step, Transition, and more. If I take a step for explaining my issue, after double click on the step a popup dialog is opened with the elements to define this step (actions on this step, and more). The issue is here, I can't see two or more step elements at the same time. I want to reuse the existing concept on other software, see this.
Step close
Step open
Dialog to add
My question is, how I can implement a dialog with my graphic element in mainframe (In this case, a step)? I don't know how I can insert a dialog with my element, I think I need to use CFormView, but I don't know.
This dialog needs to be resizable and reduce directly by the step graphic.
any idea?
Thank you in advance! Sorry for my English ..
Sorry, I think my request is not clear .. (Thank you for your answer)
The context, it's an SDI application with the Document/View architecture. Actually the view is derived from CScrollView.
So, in the document class, you have the different lists of components for make SFC (Steps, transitions and symbols ..). I'm working today on Step element.
The user inserts a new step, the step is draw on the view like this :
enter image description here
And now the user want change the events on this Step, for this after double click on the step the events editor is opened at right of step draw, like this :
enter image description here
For this, I've created a new dialog resource and create the class by wizard in CForwView derived class. In step attribute, you can find one instance of this derived class (The derived class of dialog).
But this doesn't work correctly, I think my method is bad. At the first try, I have sent the pointer of the current document to the "CFormView::Create" function for having the "Save" button active with the focus on the FormView. But after destroying the step, the instance of FormView is destroyed and the document with the instance of formview ...
No problem, you can use "Create" within CCreateContext a null pointer. But with the document or without I have a lot of problems (graphic design not correct in FormView, regularly (not systematic I have assert fail on Proc exchange (for differents reason)). But the "concept" is good, the editor follows the draw if I scroll, I can open or close the editor at any time and on any elements.
For the old capture, it's my SFC designer "model". My application is a complement to this application, so I want a similar design. I don't know how work my model application ..
On my application all is draw by MFC GDI, I don't use ActiveX or other tools.
So what is the correct way to implement one instance of editor by instance of step ?
For the implementation on this FormView I have :
- Make new dialog in ressource
- Create a derived class of CFormView with the created dialog
- Add one instance in attributes of Step element
- "OnDbClickOnStep" -> Call "Create" with the good position / size, pointer of mainview (in my case the CSrollView derived class)
- Done, FormView inserted in a mainview, I can edit my step events.
? Not done, I lost save button and other function linked to the document with the focus on a control in FormView. The app want a document with this view, how to override this ?
? Error in Proc exchange, for different reason...
You have an idea ?
You normally don't draw anything in the "main frame" (or the "MDI clild frames", in the case of a MDI application), this is done by the library, and imo sufficiently so. You display your data in a CView-derived class.
CView is the base class of all other MFC view classes. It's a simple graphical class - you need to paint it yourself in the OnDraw() member.
CScrollView is a descendant of CView, adding scrolling functionality (scroll-bars are automatically displayed if the scrollable area is bigger than the visible window area).
CFormView is a descendant of CScrollView, displaying a dialog resource-script, containing "controls" (edit-boxes, check-boxes, images, ActiveX etc).
As in your case the "controls" won't be initially known (except maybe for some few special cases) and rather programatically created, the resource script will most likely be empty, so using either CFormView or CScrollView will basically be the same. I would suggest starting with CFormView, and "downgrade" it to CScrollView if CFormView is not necessary or causes you troubles.
What are those "Step" items shown in the pics? ActiveX controls, child dialogs maybe? These work best as child controls on a dialog window. Are they already implemented, or they are just pics of some other software? Btw ActiveX is a way to define controls that can be used in other projects too, without having to include them in the project source.
Windows 8.1
Rails 4.1
Ruby 2.0
I have the menus for my application defined in views/layout, and one of those is the header where I have the menu items. There are some additional partials rendered form _header.html.erb as well.
I would like to have an additional menu appear ONLY when I render views/pages/index. How do I go about doing this?
I would look in Javascript. Have you tried listening for the specific body class of that page? Each body gets a dynamically generated attribute of class="controller action". If you listen for body.controller.action, you'll have the event that can trigger you to show (or hide) your menu item.
Pseudo code might look like:
I want a new menu to appear for controller1, action1
when any action fires in any controller
if the class of the body element has both class "controller1" and class "action1"
menu.show()
else
menu.hide()
I have MDI application with Document/View enabled.
Inside CView class of the application there are created several CWnd derived child windows(different views) and then placed inside tab control (CMFCTabCtrl), which is also created in application CView class. So, I can see tabs inside each application document and by switching between these tabs, see each child view. For example, one view with OpenGL data visualization, another with text editor window, third with table visualization and so on.
Now, I want to add possibility to see all created child views simultaneously, separated with split control inside one document and switch between this new layout to tabbed layout, mentioned above, and vice versa by menu command.
So, I wonder what is the best way to accomplish my task
Thank you in advance
The SWSPLIT sample app on MSDN does just about everything that can be done with views and splitters.
http://support.microsoft.com/kb/199515/en-us
I'm using an MFC application with a toolbar.
I need to use a button of this toolbar in some class.
But, i don't find how to map the toolbar button events to methods of my class.
I saw in the property menu that i can map an event to a method. but there the name the the button is not in the events list.
The button is already used in other classes.
So how to map a toolbar button in my class ?
The only classes that receive toolbar messages are view windows, the mainframe, the document and the CWinApp. Toolbar/Menu messages are not routed to other classes. Your question would be clearer if you explain what kind of class you are trying to add the toolbar message handler into.
Another problem is that the Visual Studio wizard assumes that there is a menu command with the same ID as each toolbar button. So it only lists menu IDs, not toolbar IDs that have no matching menu command. But you can easily map a toolbar button to a class method without the wizard's help by putting a line like this in the class message map:
ON_COMMAND(ID_NEW_TOOLBUTTON, OnNewToolbutton)
But it will only work in the above mentioned classes that receive toolbar messages.
I've derived a custom control from ATL::CWindowImpl<CMyCustomControl> and declared DECLARE_WND_CLASS(_T("CMyCustomControl")).
I've also made a dialog resource with a custom control with the class name CMyCustomControl.
How do I go about registering the control properly so I can display it on the dialog?
There are thre typical way to create custom controls in WTL.
DECLARE_WND_CLASS/DECLARE_WND_SUPERCLASS + RegisterClassEx API to register class by name + custom control reference in dialog template to instantiate control through class name
Implement window class, esp. inheriting from CWindowImpl, and create control manually, esp. from OnCreate/OnInitDialog
Implement window class, instantiate standard control through dialog template, and subclass the control instance to alter its behavior (e.g. static with hyperlinks, custom list view, edit control with color highlighting etc)
With all three you need to do more than just a macro in class definition. You will find great examples here: http://www.viksoe.dk/code/all_wtl.htm under "Controls" section.
Certainly the fourth method is implementing an ActiveX control.