create divider between header and menu in navigationview for drawerlayout - android-navigationview

For a navigationview, we can create a divider between two items by putting them in two groups. But how can we create a divider between a header and menu? I tried to make an empty group at the top of the menu, but it doesn't work.
The default theme for navigationview looks quite cool, but I like the black & white style. But it looks quite awkward when I can't create a divider between the header and menu (sad)

I don't know what's the proper way to do it, but I have some workaround for it:
As mentioned by P. Ilyin, you can put the divider on the bottom of your header view.
You can add the divider onto the NavigationView layout, and manually adjusting the divider position.
Example:
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/drawer_menu_header"
app:menu="#menu/menu_drawer">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/background_gray"
android:layout_marginTop="140dp"/>
</android.support.design.widget.NavigationView>
In this case, we make a custom gray line divider that has 1dp height, and it positioned under the menu header (140dp is the height of this menu header).

Related

SwiftUI - How to make part of a Text Navigation Link in iOS 13?

I have Two Text views containing a bold part and a not bold part added by + operator in SwiftUI. Like Below:
Text(AppStrings.dummyName)
.bold()
+ Text(" \(AppStrings.dummyMemberRequest)")
I want to turn the Bold part into a NavigationLink. But it is not possible as + Operator only works with Text view.
How can I turn a part of the Text view into a NavigationLink in SwiftUI, iOS 13?
You can just use Markdown syntax instead of combining them like that
Text("This is a text with **bold** words")

Where do I set fields that can be edited in Sitecore editor options?

Where in sitecore do I configure what fields are displayed when I click this button? (Currently, it lists 3 of the 7 fields that are on the template, I'd like to add another to be editable).
Screenshot
It is one of Edit Frame buttons. When you open your control markup, you see something like this:
<sc:EditFrame ID="editFrame" runat="server" Buttons="/sitecore/content/Applications/WebEdit/Edit Frame Buttons/Default">
...
</sc:EditFrame>
It differs for MVC, but is similar. You need to get Buttons attribute value.
When you open /sitecore/content/Applications/WebEdit/Edit Frame Buttons/Default path in core database you see list of children. It is your buttons. For your case it should be only one button: Edit Item. This item has Fields field where using pipe as delimiter is list of fields that are available for editing.

How to toggle visibility action bar tab navigation?

I use Action Bar Sherlock library.
In SherlockFragmentActivity, Make tabs and pager (Swipe + Tab)
actionBar.addTab(actionBar.newTab().setText("tab1").setTabListener(this));
actionBar.addTab(actionBar.newTab().setText("tab2").setTabListener(this));
actionBar.addTab(actionBar.newTab().setText("tab3").setTabListener(this));
When paging. I change tab.
When tab selected, I change page.
(These works fine.)
And make button to toggle visiblity.
actionBar.setNavigationMode(NAVIGATION_MODE_TABS); // this force tab index = 0
//or
actionBar.setNavigationMode(NAVIGATION_MODE_DEFAULT);
But Setting navigation mode to NAVIGATION_MODE_TABS,
make tab index = 0 not current tab(pager) index
Try storing current tab index to an integer before you call actionBar.setNavigationMode(NAVIGATION_MODE_TABS);
int index=actionBar.getSelectedNavigationItem();
actionBar.setNavigationMode(NAVIGATION_MODE_DEFAULT);
actionBar.setNavigationMode(NAVIGATION_MODE_DEFAULT);
actionBar.setSelectedNavigationItem(index);

Add custom HTML class property to selected block in a QTextEdit

I am not new to Qt, but I can't find how to add a custom css class to the selected block in a QTextEdit.
As far as I know,format is changed whit code like this:
QTextCursor cursor = textEdit->textCursor();
QTextBlockFormat bfmt;
// Apply format changes
cursor.setBlockFormat(bfmt);
When I do this, the generated HTML code creates a span with inlined style in it, but what I want is to insert the css class:
<SPAN class='myclass'>text</span>
I am missing a function inside QTextBlockFormat to set the css class of the text.
You should be able to emulate this behavior by manually adding <span style=""> tags to your selected text:
QString oldText = cursor.selectedText();
// not the best way to concat three strings, but for example only...
cursor.insertHtml(QString("<span class=\"%1\">%2</span>").arg("myclass").arg(oldText));
selectedText() will return currently selected text, and insertHtml() will insert new text at the beggining of the cursor, deleting current selection, if any.

QT - multi-select

I would like to create a search-type text field in QT that can contain both standard text as well as what I would call "tags"... basically additional search terms that are individually highlighted and separated. I envision this looking like the multi-select in "Chosen" (Javascript library). http://harvesthq.github.com/chosen/
I have been unable to find anything similar through searching. It also seems that the standard QT text box types are not designed to have "sub-widgets".
It appears that QTextEdit supports HTML... that might be a possiblity... but the docs are not very clear to me as what is supported in terms of CSS (which I think would be required to get the desired formatting). http://doc.qt.io/qt-5/qtextedit.html#html-prop
Its funny... I got to the bottom of this submission page and realized I have to tag this (this is my first SO question)... This tag-adder box is almost exactly what I want!
There is no ready-to-use soultion that I know.
If I were to try implementing it, I would definitely use widget with layout, in which there are two types of child widgets: LineEdits (borderless to look like actual part of bigger widget) and buttons - code managing line edit changes would simply add new buttons before or after and if necesary splited linedit into tw with button between. This way is not interfering with qt programers intentions on how to use widgets and how to make them all fit together in one style.
If you want you can use custom widgets instead of buttons to provide remove icon.
As I wrote in my comment - if i have a bit more time I will try to make something like that myself.
Here is a very simple implementation of putting buttons in a QLineEdit as a user types, written in Python:
from PySide.QtCore import *
from PySide.QtGui import *
class Entry(QLineEdit):
def __init__(self):
QLineEdit.__init__(self)
self.buttons = []
self.backupText = ''
self.textEdited.connect(self.on_change)
self.layout = QHBoxLayout()
self.setLayout(self.layout)
self.layout.addStretch()
marginz = QLabel(' ')
marginz.show()
margin = marginz.width()
marginz.hide()
self.layout.setContentsMargins(margin, margin, margin, margin)
def on_change(self):
if self.text()[-1] == ' ' and not self.text().endswith(' '):
if len(self.text()) > len(self.backupText):
self.setText(self.text() + ' ')
self.buttons.append(QPushButton(self.text().split()[-1]))
self.layout.insertWidget(self.layout.count()-1, self.buttons[-1])
else:
self.setText(self.text()[0:-1])
self.buttons[-1].hide()
del self.buttons[-1]
self.backupText = self.text()
app = QApplication([])
window = QMainWindow()
window.setStyleSheet(
'QPushButton {border: 1px solid gray; background: lightgray; color: black;}')
entry = Entry()
window.setCentralWidget(entry)
window.show()
app.exec_()
It creates a QHBoxLayout and adds a button to it for each word you type, and takes the button away when you get rid of the word.
If you want to put a close button inside of each of the sub-widgets, you can make a custom widget for that too.
EDIT
As j_kubik's comment stated, systems with wide-margin buttons would cause the tag buttons to overlap the text a user is currently typing. I have modified the code to enforce the margins of the buttons inserted (with stylesheets), added an extra space for each space the user types, and set the QHBoxLayout's contentsMargins to be the same width as a space (""). Now the buttons will not overlap the text inserted.