I have a simple webView object and I want create a text link on the webView to manually. I do not want to have the text link from a external server. I want create a text link to manually on my webView. Is this possible?
In XML file:
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click"
android:layout_margin="10dp"
android:layout_gravity="center"
android:textSize="20sp"/>
<WebView
android:id="#+id/webView"
android:layout_width="fill_parent"
android:layout_height="match_parent"/>
In Class onCreate() :
mTextView = (TextView)findViewById(R.id.textView);
mWebView = (WebView) findViewById(R.id.webView);
mTextView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com");
}
});
You should add a TextView with the text, the text itself doesn't matter, but you have to use an url while coding.
Set onClick and clickable to the Textview:
<TextView
android:id="#+id/txtView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="onTextViewClick"
android:text="Click this text"
/>
And handle it:
TextView mTxtView = (TextView) findViewById(R.id.txtView);
mWebView = (WebView) findViewById(R.id.webView1);
String url = "https://www.google.com"
public void onTextViewClick(View v) {
if(v.getId() == R.id.txtView){
mWebView.loadUrl(url);
}
Related
Hi Guys I am trying to show Progress bar and Text view at a time but Text View only displays once and disappears. Below is my Java File:
public class MainActivity extends Activity {
public boolean show_splash;
ProgressBar progressBar;
#Override
public void onCreate(Bundle savedInstanceState) {
show_splash = true;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myWebView = (WebView) findViewById(R.id.webview);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
//enable Javascript
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setAllowContentAccess(true);
webSettings.setAppCacheEnabled(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDomStorageEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setSupportMultipleWindows(true);
webSettings.setSupportZoom(true);
webSettings.setLoadsImagesAutomatically(true);
//loads the WebView completely zoomed out
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(true);
myWebView.setWebViewClient(new MyWebViewClient());
myWebView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
});
//load the home page URL
myWebView.loadUrl("http://mvc.myorange.ca/");
}
public void Visible(){
WebView webview = (WebView) findViewById(R.id.webview);
//ImageView logo = (ImageView) findViewById(R.id.imageView1);
TextView Text =(TextView) findViewById(R.id.textView1);
if (show_splash){
webview.setVisibility(View.INVISIBLE);
//logo.setVisibility(View.VISIBLE);
Text.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.VISIBLE);
show_splash=false;
}
else {
webview.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.VISIBLE);
Text.setVisibility(View.INVISIBLE);
//logo.setVisibility(View.INVISIBLE);
}
}
public void Invisible(){
WebView webview = (WebView) findViewById(R.id.webview);
//ImageView logo = (ImageView) findViewById(R.id.imageView1);
webview.setVisibility(View.VISIBLE);
//logo.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.GONE);
}
public class MyWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Uri.parse(url).getHost().equals("mvc.myorange.ca")) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
#Override
public void onPageStarted(WebView view, String url, Bitmap facIcon) {
Visible();
}
#Override
public void onPageFinished(WebView view, String url) {
Invisible();
}
}
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
WebView myWebView = (WebView) findViewById(R.id.webview);
if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {
myWebView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
and following is my activity xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:gravity="center"
tools:context=".MainActivity">
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"/>
<ProgressBar
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:id="#+id/progressBar"
android:layout_marginBottom="30dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF"
android:textSize="65dp"
android:background="#0582FF"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:gravity="center_vertical|center_horizontal" />
</RelativeLayout>
Now the problem is that the text view appears only once and it disappears. I would like it to be displayed first time along with the progress bar which comes after the textview. can anyone point out where i am wrong please ??
Make use ProgressDialog instead of ProgressBar, if you want to load the text with dialog
Do one thing.. try to remove this line
Text.setVisibility(View.INVISIBLE);
and tell me whether the textview stays there or still gets disappeared
A couple of comments for getting a better code.
-The name of variables should be in lowercase. TextView text.
-findViewById() is an expensive call, you should do it in the onCreate method and save all the views as variable to save calls, like you did with ProgressBar but with all of them.
Only a couple of good practices.
I found the error, the problem is that you put the TextView to extend from top to bottom and from start to the end, then it only shows itself. Remove those statements!
Change the layout to this one and see the differences:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:gravity="center"
tools:context=".MainActivity">
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Texto cualquiera"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF"
android:textSize="65dp"
android:background="#0582FF"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:gravity="center_vertical|center_horizontal" />
<ProgressBar
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#+id/textView1"
android:layout_gravity="center"
android:id="#+id/progressBar"
android:layout_marginBottom="30dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webview"
android:layout_below="#+id/progressBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"/>
</RelativeLayout>
This Class
package com.example.foootnotes;
import android.app.Activity;
import android.app.Dialog;
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;
public class compare extends Activity {
WebView web1;
WebView web2;
Button btn;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.compare);
// String str1="<html>This first Html data</html>";
String str2 = "<br /><br />Read the handouts please for tomorrow.<br /><br /><!--homework help homework"
+ "help help with homework homework assignments elementary school high school middle school"
+ "// --><font color='#60c000' size='4'><strong>Please!</strong></font>"
+ "<img src='http://www.homeworknow.com/hwnow/upload/images/tn_star300.gif' />";
Intent i = getIntent();
String str1 = i.getStringExtra("htmlrespones");
web1 = (WebView) findViewById(R.id.webfirst);
web2 = (WebView) findViewById(R.id.websecond);
web1.loadDataWithBaseURL("", str1, "text/html", "UTF-8", "");
web2.loadDataWithBaseURL("", str2, "text/html", "UTF-8", "");
btn = (Button) findViewById(R.id.compare);
btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
WebView web5 = (WebView) findViewById(R.id.webView1);
WebView web6 = (WebView) findViewById(R.id.webView2);
web5.loadDataWithBaseURL("", "This is first ", "text/html",
"UTF-8", "");
final Dialog dialog = new Dialog(compare.this);
dialog.setContentView(R.layout.custom);
dialog.setTitle("Differences");
Button dialogButton = (Button) dialog
.findViewById(R.id.dialogButtonOK);
dialogButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
}
}
my custom .xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp" />
<TextView
android:id="#+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/image"
android:textColor="#FFF" />
/>
<Button
android:id="#+id/dialogButtonOK"
android:layout_width="100px"
android:layout_height="wrap_content"
android:layout_below="#+id/image"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:text=" Ok " />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
</LinearLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/dialogButtonOK"
android:layout_marginTop="41dp"
android:text="This is for first Html"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1"
android:layout_alignBottom="#+id/textView1"
android:layout_alignParentRight="true"
android:text="This is for scond Html" />
<WebView
android:id="#+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignRight="#+id/textView1"
android:layout_below="#+id/textView1" />
<WebView
android:id="#+id/webView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignLeft="#+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/webView1" />
</RelativeLayout>
I am able to Display Textview But i want display data in web view in custom Dialog when i display it is in Textview it working Fine But i have display large data in Webview i cant display data in Textview so please tell how i display data in webview within Coustome dilog ..Please Help!
Try this
String str2 = "<br /><br />Read the handouts please for tomorrow.<br /><br /><!--homework help homework"
+ "help help with homework homework assignments elementary school high school middle school"
+ "// --><font color='#60c000' size='4'><strong>Please!</strong></font>"
+ "<img src='http://www.homeworknow.com/hwnow/upload/images/tn_star300.gif' />";
btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
final Dialog dialog = new Dialog(compare.this);
LayoutInflater layoutInflater = (LayoutInflater)compare.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.Your_layout, null);
dialog.setContentView(layout);
dialog.setTitle("Differences");
Button dialogButton = (Button) layout
.findViewById(R.id.dialogButtonOK);
WebView web5 = (WebView) layout.findViewById(R.id.webView1);
WebView web6 = (WebView) layout.findViewById(R.id.webView2);
web5.getSettings().setJavaScriptEnabled(true);
web5.loadDataWithBaseURL(null, str2, "text/html",
"UTF-8", null);
dialogButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
Your Xml is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<WebView
android:id="#+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignRight="#+id/textView1"
android:layout_below="#+id/textView1" />
<WebView
android:id="#+id/webView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignLeft="#+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/webView1" />
<Button
android:id="#+id/dialogButtonOK"
android:layout_width="100px"
android:layout_height="wrap_content"
android:layout_below="#+id/image"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:text=" Ok " />
</RelativeLayout>
XML Layout
<LinearLayout style="#style/behindMenuScrollContent"
android:paddingTop="25dp" >
<TextView
style="#style/behindMenuItemTitle"
android:text="People" />
<LinearLayout
android:id="#+id/iconViewLink4"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<jp.fureco.IconView
android:id="#+id/iconViewItem4"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textSize="20dp"/>
<TextView
android:layout_marginLeft="10dp"
style="#style/behindMenuItemLabel"
android:text="Visitor" />
</LinearLayout>
</LinearLayout>
Then I have myWebView just like this
WebView myWebView = (WebView)findViewById(R.id.webView1);
When a user clicks on iconViewLink4, I want it jump to the url "http://example.com/messsage"
How can I code that?
Yes you can. Just use android:onClick="methodName" in <LinearLayout> or add it programatically by using setOnClickListener like
LinearLayout linLay = (LinearLayout)findViewById(R.id.iconViewLink4);
linLay.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// the method or code that will take control to your URL
}
}
Make it clickable and give it an OnClickListener (you can do this on any View)
<LinearLayout
android:id="#+id/iconViewLink4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true">
findViewById(R.id.iconViewLink4).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// do something here
}
});
i have created a webview for my android application , inicially i am tying to take application simpler as possible to understand things . i have created a webview to display the different page in it . i simply created a button which load url into webview which is working perfectly fine ,but the webview is loading the urls below the button . it is not overriding the main layout or not opening the url in newpage. i see the webpage in webview and the button above it . how can get rid of this button. thanks in advance. here is my java and xml code
activity
public class TestinglinkActivity extends Activity {
final Activity activity = this;
WebView webview;
private class MyWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new MyWebViewClient());
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if(progress == 100)
activity.setTitle(R.string.app_name);
}
});
Button btn_login = (Button) findViewById(R.id.btn_click_login);
btn_login.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
webview.loadUrl("http://www.google.com.pk");
webview.goBack();
webview.goForward();
}
}
);
}
}
xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="outsideInset"
android:scrollbars="vertical"
android:scrollbarSize="10dp"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="#+id/btn_click_login"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="2"
android:text="GO"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_marginRight="5dp"
android:layout_alignParentLeft="true"
android:gravity="center_vertical"
android:lines="4"
/>
<ImageView android:id="#+id/imageBtn"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:padding="5dp"
android:contentDescription="#string/hello"
android:layout_alignParentLeft="true"
/>
</RelativeLayout>
<TextView
android:id="#+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:gravity="center_vertical"
android:lines="4"
/>
<WebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</ScrollView>
It sounds to me like you want to start a new Activity when the button is pressed. The reason your WebView appears below the other layout is because that's exactly what your XML describes. If you want your WebView to appear full screen, you need to move the WebView to a separate Activity which is started when your button is clicked.
You probably will want to pass the URL in the Extra of the Intent used to start the new Activity.
I've got four Image Buttons in screen1.xml.
I've defined the webview in screen3.xml.
If i click the ImageButton1 or other buttons, the repective URL (in webview) should load in screen3.xml.
I tried to do this, but it throws forceclose error. But If I try the same this with webview defined in screen1.xml, it works. But the problem is the Image Buttons and the webview appears in the same page and they are overlapped which looks awful!
Please help me out to open the webview in a new screen.
BTW, can addView be used for this purpose?
public class click extends Activity
{
private WebView webView;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.screen1);
webView = (WebView) findViewById(R.id.web_view);
ImageButton i1 = (ImageButton) findViewById(R.id.imagebutton1);
ImageButton i2 = (ImageButton) findViewById(R.id.imagebutton2);
ImageButton i3 = (ImageButton) findViewById(R.id.imagebutton3);
ImageButton i4 = (ImageButton) findViewById(R.id.imagebutton4);
}
private void openBrowser1()
{
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("myurl");
}
public void myClickHandler1(View view)
{
openBrowser1();
}
Screen1.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView
android:id="#+id/web_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" />
<ImageButton android:id="#+id/imagebutton1" android:clickable="true" android:onClick="myClickHandler1"
android:layout_width="130dip" android:background="#null" android:layout_height="130dip" android:layout_x="21dip"
android:layout_y="61dip" ></ImageButton>
<ImageButton android:id="#+id/imagebutton2" android:clickable="true" android:onClick="myClickHandler2"
android:layout_width="130dip" android:background="#null" android:layout_height="130dip" android:layout_x="171dip"
android:layout_y="61dip" ></ImageButton>
<ImageButton android:id="#+id/imagebutton3" android:clickable="true" android:onClick="myClickHandler3"
android:layout_width="130dip" android:background="#null" android:layout_height="130dip" android:layout_x="21dip"
android:layout_y="241dip" ></ImageButton>
<ImageButton android:id="#+id/imagebutton4" android:clickable="true" android:onClick="myClickHandler4"
android:layout_width="130dip" android:background="#null" android:layout_height="130dip" android:layout_x="171dip"
android:layout_y="241dip" ></ImageButton>
</AbsoluteLayout>
screen3.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView
android:id="#+id/web_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" />
</AbsoluteLayout>
I think you need some fix to your code...
public class click extends Activity {
private WebView webView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen1);
webView = (WebView) findViewById(R.id.web_view);
ImageButton i1 = (ImageButton) findViewById(R.id.imagebutton1);
ImageButton i2 = (ImageButton) findViewById(R.id.imagebutton2);
ImageButton i3 = (ImageButton) findViewById(R.id.imagebutton3);
ImageButton i4 = (ImageButton) findViewById(R.id.imagebutton4);
WebSettings webSettings = webView.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(false);
webView.loadUrl("http://www.reforma.com");
//Add a listener to ImageButton1
i1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
openBrowser1();
}
});
}
private void openBrowser1()
{
//this intent is used to open other activity wich contains another webView
Intent intent = new Intent(click.this,SecondActivity.class);
startActivity(intent);
}
}
screen1.xml
<WebView
android:id="#+id/web_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageButton android:id="#+id/imagebutton1" android:clickable="true"
android:layout_width="130dip" android:layout_height="130dip" android:layout_x="21dip"
android:layout_y="61dip" ></ImageButton>
<ImageButton android:id="#+id/imagebutton2" android:clickable="true"
android:layout_width="130dip" android:layout_height="130dip" android:layout_x="171dip"
android:layout_y="61dip" ></ImageButton>
<ImageButton android:id="#+id/imagebutton3" android:clickable="true"
android:layout_width="130dip" android:layout_height="130dip" android:layout_x="21dip"
android:layout_y="241dip" ></ImageButton>
<ImageButton android:id="#+id/imagebutton4" android:clickable="true"
android:layout_width="130dip" android:layout_height="130dip" android:layout_x="171dip"
android:layout_y="241dip" ></ImageButton>
</AbsoluteLayout>
Add a new activity wich contains your webview where the webpage should be load!.
public class SecondActivity extends Activity {
private WebView webView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen3);
webView = (WebView) findViewById(R.id.web_view);
WebSettings webSettings = webView.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(false);
webView.loadUrl("http://www.reforma.com");
}
}
screen3.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView
android:id="#+id/web_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</AbsoluteLayout>
Add to your AndroidManifest.xml your second Activity
<activity android:name=".SecondActivity"
android:label="SecondActivity"/>
and you must have Internet permission to load the web page...
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
any doubts???
Jorgesys
It doesn't look like you're inflating and loading the screen3.xml layout anywhere, so attempts to reference the WebView it contains will probably generate an exception. Sounds like what you really want to do is define another Activity for the webview layout and swap to it when the user pushes one of the buttons. See the 2nd part of the Notepad sample for a description of how to add additional Activities to an application and swap between them:
http://developer.android.com/resources/tutorials/notepad/notepad-ex2.html