switch / if statement, efficiency question

by Kent Yip » Thu, 30 Apr 2009 01:44:23 GMT


Sponsored Links
 a switch statement is made for nested if statements.

switch statement is greate if you have a bunch of selections, to make a
switch statement perform better you have to look at what user will likely
selection the most, and implement that case on the top most case in the
switch. Accessing that case will be faster than accessing cases at lower end
of the switch statement.








--~--~---------~--~----~------------~-------~--~----~



switch / if statement, efficiency question

by Kent Yip » Thu, 30 Apr 2009 04:35:45 GMT


 thx fadden for the info.






--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Smaller tabs, such as the Facebook official app



You can try using setView() to control the contents of the tabs:

http://stackoverflow.com/questions/2170200/tabwidget-how-to-set-position-of-indicator-text

I haven't yet experimented with this to see if that affects the tab
heights or not.

If you can find an APK with the smaller tabs, you can always toss that
into an emulator and use hierarchyviewer to try to figure out how they
pulled it off. Alas, hierarchyviewer does not work on devices. :-(

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in US: 22-26 February 2010: http://onlc.com

-- 

2. DOMException while cloning XML Node

Hi,

The cloneNode methon in the following minimal example works on java
1.6 but throws an DOMException with code 14 under android 5.

Code 14 according to sdk dok means:
"NAMESPACE_ERR
If an attempt is made to create or change an object in a way which is
incorrect with regard to namespaces."

Has anybody an idea why this might be?
Thank you in advance!

-------------------------------------------------------------------------------------------

public class M
{
        public static void main(String[] args)
        {
                try
                {
                    DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
                    DocumentBuilder builder = factory.newDocumentBuilder();

                    String text = new String("<blub></blub>");
                    Document document = builder.parse(new InputSource( new
StringReader(text) ));

                    document.getDocumentElement().cloneNode(true);
                }
                catch(DOMException e)
                {}
                catch(ParserConfigurationException e)
                {}
                catch(IOException e)
                {}
                catch(SAXException e)
                {}
        }
}
-------------------------------------------------------------------------------------------

-- 

3. Host is unresolved

4. video streaming in android

5. Upgrading android 1.1 platform to android 1.5

6. Store image and video from the web into the sdCard

7. Reposition views att runtime