I want to open a web view instead of Browser whenever I click link on my textView - browser

I have a lot of input text that contains linked URL on the textview field. I just want to set to default whenever I clicked any link on the textview it will pop up the webView instead of the browser.Thanks

https://developer.apple.com/library/ios/documentation/uikit/reference/UITextViewDelegate_Protocol/Reference/UITextViewDelegate.html
you can use this function from UITextViewDelegate:
(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange{
NSLog(#"URL %#",URL); // URL
// pop webkit
return NO;
}

Related

Android Xml File Button Hidden

In My Android Application, i have to hide button based on some condition,if condition is true than button is hide,otherwise it appear as it is, so for hide facility i'm using button's buttonID.setVisibility(View.INVISIBLE),so that button is hidden but it take space in xml file,so please suggest me to button is hidden and don't take space in xml file
visible - This means visible and it takes space.
invisible- This means invisible and it takes space.
gone- This means invisible and it DOESN'T takes space.
Use it as follows:
Visible tag in XML
android:visibility="visible"
Visible code in java
view.setVisibility(View.VISIBLE);
Invisible tag in XML
android:visibility="invisible"
Invisible code in java
view.setVisibility(View.INVISIBLE);
Gone tag in XML
android:visibility="gone"
Gone tag in java
view.setVisibility(View.GONE);
you should use View.GONE instead of View.INVISIBLE
As what #Tim suggested,you can always change the layout parameters for the elements not just set it's visibility to VISIBLE or GONE
Here the sample. Assume checkBox is clicked
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
buttonID.setVisibility(View.GONE);
}
else{
buttonID.setVisibility(View.VISIBLE);
// now settings the new parameters
AbsoluteLayout.LayoutParams params = ((AbsoluteLayout.LayoutParams) buttonID.getLayoutParams());
params.x = 100; // the new value
params.y = 100; // the new value
buttonID.setLayoutParams(params);
}
});
Source : Android: how to change layout_x, layout_y in an AbsoluteLayout dynamically?

Xamarin side menu tap issue

I developed an app using Xamarin forms that has side menu see this url.
But I couldn't use this in my current project, so I made my custom component for side menu.
How to implementing feature that hide menu when I tap range out of side menu?
It is hard to give you any help without seeing your code, but generally I tackle this issue by adding a ContentView that covers the screen when ever your menu opens. The menu would be displayed on top of the ContentView. Then you add a TapGestureRecognizer to the ContentView which closes the menu when clicked.
You could add some color to the ContentView but make it opaque so it is see-through, something like this color: #74787878
ContentView backgroundView = new ContentView {
BackgroundColor = Color.FromHex("#74787878"),
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Content = //Your menu
}
backgroundView.GestureRecognizers.Add(new TapGestureRecognizer {
Command = new Command(() => {
//Remove the background and hide the menu
})
});

Is this a bug in the Tab Container?

I think this is a bug in the Tab Container...
Opening a new tab using Java or the Server Side JavaScript createTab method when the new tab contains a panel that is set to be an iframe pointing to another XPage in the same database will always cause the XPage to get reloaded after loading about five or six tabs (in Chrome, IE does the same but it takes more tabs...)
If the tab contains an iframe that points to another database that holds the XPage it works fine.
The SSJS code is:
getComponent("djTabContainer1").createTab({title:"New tab"});;
The Java code is
public static boolean createTab(UIDojoTabContainer tabContainer) {
try {
if (tabContainer == null) {
tabContainer = (UIDojoTabContainer) Utils.findComponent("TabContainer");
if (tabContainer == null) {
return false;
}
}
String tabTitle = null;
String url = null;
String unid = null;
UIDojoTabPane newTab = null;
// get default number from current project preferences
tabTitle = "My Tabpage";
url = Utils.GetXpageURL("tabpage.xsp");
// create a new Tab
newTab = new UIDojoTabPane();
newTab.setTitle(tabTitle);
newTab.setTabUniqueKey(new Random().toString());
newTab.setClosable(true);
newTab.setId("TabContainer_" + unid);
newTab.setStyleClass("myTabContainer");
Utils.WriteToConsole("setting style class on " + newTab.getTitle());
// newTab.setStyle("height:auto;width:auto; overflow-y: auto;border: 0px;");
// create new Panel
UIPanelEx newPanel = new UIPanelEx();
newPanel.setId("IFrame" + unid);
newPanel.setStyleClass("iframeClass");
// make an iFrame of this panel with our URL as src
newPanel.setTagName("iframe");
Attr property = new Attr();
property.setName("src");
property.setValue(url);
newPanel.addAttr(property);
// add Panel to our new Tab
newTab.getChildren().add(newPanel);
// add the new tab to our tab container
tabContainer.getChildren().add(newTab);
tabContainer.setSelectedTab(unid);
return true;
} catch (Exception ex) {
Utils.WriteToConsole("Unable to add a new Tab Page to the Tab Container (com.tlcc.Main.createTab)", ex);
return false;
}
}
The XPage that is referenced in the src property of the iframe is very basic...
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:button
value="Label"
id="button1">
</xp:button>
<xp:inputText id="inputText1"></xp:inputText></xp:view>
When the XPage reloads it has no more tabs (except the first tab that was created in the XPage at the start) and is not responsive.
Howard
It could be a server page persistence/component tree limit problem. If you use the default server page persistence, the server only stores 4 pages in memory (per user).
When you create new tabs on the page that loads another XPage, the server is filling up the server page persistence queue and when you hit the 5th tab, the current page is no longer part of the server page persistence (the component tree is no longer in memory) leading to a reload of the current page.
You can increase the number of pages stored (and also move the disk persistence instead of memory persistence). You can also set viewState to "nostate" on the XPage that you load in the iframe (at least to test out my theory).
See Toby Samples blog post on state and this answer on a similar state issue: https://stackoverflow.com/a/31431917/785061
So, to finalize this... the setting for viewstate=nostate allows more tabs but then does not keep the components in memory. So, it works well for readonly XPages but not when the document on the XPage is in edit mode. The setting Maximum Pages on disk in the Xsp properties on the persistence tab will allow more tabs with iframes that have XPages but still will crash at some point.
Net is, don't use multiple iframes that pull in XPages from the same nsf...

LWUIT move all commands from the form to the "slide context menu"

I am trying to make a calculator for nokia 501 asha and i want all my buttons to fit on the the screen so that i don't have to scroll the form to access all buttons.
Apparently adding commands like exit,about and help are mandatory to your app.
Now when i add these commands one of the commands appear as a button and occupy a lot of screen space which i don't want.
I want my commands to appear like this i.e all commands on the slide context menu.
But instead there's an unnecessary button on the screen.
The code that i have used to add commands is as follows:
Form a = new Form("form");
a.addCommand(new Command("exit"),0);
a.addCommand(new Command("HELP"),1);
a.addCommand(new Command("ABOUT"),2);
a.setEnabled(true);
a.show();
So, what modifications i need to make in that code so that all my commands appear on the slide context menu ?
I am looking the Asha UI Component Demos, in the Menu section, options menu. I find this code to add the Commands:
// The rest appear in menu
Command menuCommand1 = new Command("Command 2", Command.SCREEN, 1);
addCommand(menuCommand1);
Command menuCommand2 = new Command("Command 3", Command.SCREEN, 2);
addCommand(menuCommand2);
Command menuCommand3 = new Command("Command 4", Command.SCREEN, 3);
addCommand(menuCommand3);
Try to put this Command.SCREEN parameter.
This answer will help to someone. The following code is working in 501.
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
Display.init(this);
// For hide the form title bar. It is working in Nokia asha 501.
Display.getInstance().setForceFullScreen(true);
Display.setObjectTrait(Display.getInstance().getImplementation(), "nokia.ui.canvas.status_zone", Boolean.TRUE);
Form a = new Form("form");
a.addCommand(new Command("exit"),0);
a.addCommand(new Command("HELP"),1);
a.addCommand(new Command("ABOUT"),2);
a.setEnabled(true);
a.show();
}

Selection type changes context menu using chrome extension

I am trying to build a chrome extension. In it I want the context menu to change according to the selected text on the page.
For example, if its a number I want a menu that says divisibility test for this numbr is ...
and if it is a string, it should have a something else, but not both at the same time.
I cant figure out how to do that.
You will have to set a listener for mouse down. There is no other way to get the selected text before the menu is created.
See this SO question:
chrome extension context menus, how to display a menu item only when there is no selection?
Here is part of the code the rest is at the link.
document.addEventListener("mousedown", function(event){
//right click
if(event.button == 2) {
if(window.getSelection().toString()) {
chrome.extension.sendRequest({cmd: "createSelectionMenu"});
} else {
chrome.extension.sendRequest({cmd: "createRegularMenu"});
}
}
}, true);

Resources