Refresh button, out of tabhost

by satie » Wed, 05 Jan 2011 03:46:00 GMT


Sponsored Links
 Hi,

here you are my problem.
When user click "refresh" in OptionsMenu, disappear Tabhost and the
app
use the simple webbrowser out of app.
I'd like to use OptionMenu "refresh" inside tab host.
My code:
public class app extends TabActivity {
        @Override



        public void onCreate(Bundle savedInstanceState) {

                super.onCreate(savedInstanceState);

                TabHost host=getTabHost();
                Intent i=new Intent(this, CWBrowser.class);

                i.putExtra(CWBrowser.URL, " http://www.website.it/" ;);
                host.addTab(host.newTabSpec("one")
                                                .setIndicator("News")
                                                .setContent(i));

                //to update tab each time it pressed
                i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

                i=new Intent(i);
                i.putExtra(CWBrowser.URL, " http://www.android.com ");
                host.addTab(host.newTabSpec("two")
                                                .setIndicator("Android")
                                                .setContent(i));
        }

        public boolean onCreateOptionsMenu(Menu menu){
                super.onCreateOptionsMenu(menu);
                Intent i=new Intent(this, CWBrowser.class);
                i.putExtra(CWBrowser.URL, " http://www.website.it/" ;);




                //We create the first group of MenuItem
                int GROUPA = 0;
                menu.add(GROUPA, 0, 0, "Refresh").setIntent(i);
                return true;


        }
}

AND CWBrowser
public class CWBrowser extends Activity {
        public static final String URL="it.app.android.URL";
        private WebView browser;

        @Override
        public void onCreate(Bundle icicle) {
                super.onCreate(icicle);

                browser=new WebView(this);
                setContentView(browser);
        browser.getSettings().setJavaScriptEnabled(true);
        browser.setWebViewClient(new HelloWebViewClient());
                browser.loadUrl(getIntent().getStringExtra(URL));

        }

        private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String
url) {
            view.loadUrl(url);
            return true;
        }
        }
}

-- 



Other Threads

1. How to copy contacts in phone to another account ?

When your SyncAdapter is initialized by the system you should get a
flag in the Bundle you receive from the SyncManager.

http://developer.android.com/reference/android/content/ContentResolver.html#SYNC_EXTRAS_INITIALIZE

So if this flag is present, copy the contacts to your account.




-- 

2. ThreadSafeConnectionManager timeout...

Hi !
I'm actually trying to do an application with a websocket persistent
connexion & some http request. So I thank I need to use
ThreadSafeConnectionManager, but I have a big problem with it : very
very often I got a "java.net.SocketException: The operation timed out"
even when the server's responding.
My code :
// class members declarations
private static HttpParams mParams;
private static SchemeRegistry mSchemeRegistry;
private static ClientConnectionManager mCm;
private static HttpClient mClient;

// code used to initiate the HttpClient
mParams = new BasicHttpParams();
mSchemeRegistry = new SchemeRegistry();
mSchemeRegistry.register(new Scheme("http",
PlainSocketFactory.getSocketFactory(), 80));
mCm = new ThreadSafeClientConnManager(mParams, mSchemeRegistry);
mClient = new DefaultHttpClient(mCm, mParams);

What am I doing wrong?
Thanks a lot.
Louis C.

-- 

3. Android MediaPlayer cannot play VoD stream from VLC server

4. GPS_SPI

5. [beginner] Analysis of the engadget app

6. about KeyStore

7. Problem konek internet Samsung Galaxy 5