So you have a ViewPager and your first page is an Android map. When you add or replace a new Fragment on the next page, your map resets when you go back to the first page.

Sadly, there is no way to retain its state. The only way you can do is to keep a reference on the map’s position by calling googleMap.getCameraPosition() and saving that in onSaveInstanceState() and restoring it in onCreate() or wherever.

Then you can reposition the map’s position and its zoom level by calling googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

Converting a mouse position to the caret position of a JTextComponent can be done by using the JTextComponent method viewToModel(). This can be pretty useful if you need to set the caret position of the component when you do a right click of the mouse.

The component can apply to JTextArea, JEditorPane and JTextPane respectively.

Languages like Java and Javascript provide a method called indexOf() that returns an int of the first position of the string key found in a string. strpos() in PHP acts differently. If it finds the substring within the string, it returns an int value of the position of the substring. If it does not, it returns a boolean instead.

I find this stupid. It would have been easier if it still returned an int value like the usual -1 to indicate it didn’t find any substring inside the string.

To do an if statement using strpos() of PHP just like this Java code:

Do this in PHP:

Notice the 2 equal sign succeeding after the exclamation point? That line checks if the statement is false. If you wish to change it to a true condition statement, just put in 3 equal signs.

Related Posts Plugin for WordPress, Blogger...