Created
January 20, 2011 12:34
-
-
Save anonymous/787824 to your computer and use it in GitHub Desktop.
This is the 1st Activity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.webkit.WebView; | |
import android.widget.Button; | |
import android.widget.EditText; | |
import android.widget.ViewFlipper; | |
public class Class1 extends Activity | |
{ | |
EditText search; | |
Button btn_search,btn_g,btn_y,btn_a; | |
WebView wv1,wv2,wv3; | |
ViewFlipper vf; | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
wv1=(WebView)findViewById(R.id.wv1); | |
wv2=(WebView)findViewById(R.id.wv2); | |
wv3=(WebView)findViewById(R.id.wv3); | |
vf=(ViewFlipper)findViewById(R.id.vf); | |
btn_g=(Button)findViewById(R.id.btn_g); | |
btn_y=(Button)findViewById(R.id.btn_y); | |
btn_a=(Button)findViewById(R.id.btn_a); | |
search=(EditText)findViewById(R.id.search); | |
btn_search=(Button)findViewById(R.id.btnSearch); | |
btn_search.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) | |
{ | |
Intent i=new Intent(Class1.this,Class2.class); | |
i.putExtra("atUserName", search); | |
//i.setData(intent.getData()); | |
startActivity(i); | |
} | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kritnu.android; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.webkit.WebView; | |
import android.webkit.WebViewClient; | |
import android.widget.Button; | |
import android.widget.ViewFlipper; | |
public class Class2 extends Activity | |
{ | |
Button btn_search,btn_g,btn_y,btn_a; | |
WebView wv1,wv2,wv3; | |
ViewFlipper vf; | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main2); | |
wv1=(WebView)findViewById(R.id.wv1); | |
wv2=(WebView)findViewById(R.id.wv2); | |
wv3=(WebView)findViewById(R.id.wv3); | |
vf=(ViewFlipper)findViewById(R.id.vf); | |
btn_g=(Button)findViewById(R.id.btn_g); | |
btn_y=(Button)findViewById(R.id.btn_y); | |
btn_a=(Button)findViewById(R.id.btn_a); | |
Bundle extraData = getIntent().getExtras(); | |
String atUserName = extraData.getString("com.kritnu.android"); | |
btn_g.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
// TODO Auto-generated method stub | |
//vf.showNext(); | |
//wv1.goBackOrForward(2); | |
//wv1.setWebViewClient(new HelloWebViewClient()); | |
wv1.loadUrl("http://www.google.com"); | |
//vf.setDisplayedChild(0); | |
} | |
}); | |
btn_y.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
wv2.loadUrl("http://search.yahoo.com"); | |
//vf.setDisplayedChild(1); | |
} | |
}); | |
btn_a.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
wv3.loadUrl("http://www.ask.com"); | |
//vf.setDisplayedChild(2); | |
} | |
}); | |
} | |
private class HelloWebViewClient extends WebViewClient { | |
@Override | |
public boolean shouldOverrideUrlLoading(WebView view, String url) { | |
view.loadUrl(url); | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment