how to redirect to particular URL while clicking on button?

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

how to redirect to particular URL while clicking on button?

Postby deepu » Wed Feb 10, 2010 12:40 pm

hi,i want to redirect to particular URL(ex: http://WWW.yahoo.com) while clicking on button.
deepu
Freshman
Freshman
 
Posts: 6
Joined: Mon Feb 01, 2010 6:03 am
Location: hyd

Top

Re: how to redirect to particular URL while clicking on butt

Postby Rahul » Wed Feb 10, 2010 1:04 pm

try something like this
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package and.test;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.view.View.OnClickListener;
  7. import android.webkit.WebView;
  8. import android.widget.Button;
  9.  
  10. public class test extends Activity {
  11.          @Override
  12.                 public void onCreate(Bundle onSavedState){
  13.                         super.onCreate(onSavedState);
  14.                        
  15.                 Button btn=new Button(this);
  16.                 btn.setText("Click me");
  17.                 setContentView(btn);
  18.                 btn.setOnClickListener(new OnClickListener() {
  19.                        
  20.                         @Override
  21.                         public void onClick(View v) {
  22.                                 // TODO Auto-generated method stub
  23.                        
  24.                                 WebView wb=new WebView(test.this);
  25.                                 wb.loadUrl("http://www.yahoo.com");
  26.                                 setContentView(wb);
  27.                         }
  28.                 });
  29.          }
  30.          
  31. }
  32.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


also add permissions for accessing INTERNET in your manifest file

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-permission android:name="android.permission.INTERNET"></uses-permission>
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

deepu wrote:hi,i want to redirect to particular URL(ex: http://WWW.yahoo.com) while clicking on button.
Rahul
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Wed Oct 01, 2008 11:16 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 4 guests