I am fairly new to Android Developing and have made it through making most of my first app and the last time I had a problem I came here and was pleased with the feedback and generosity of members to help so I figured I'd try again.
The current problem I am having is trying to use the buttons on my menu page to open a webpage. There are four buttons on the menu, each will open a different webpage when clicked.
If I could just get an example to open up one of them I could easily figure out the others.
Do I need to create a new xml/.java for each of the buttons?
This is the xml for my menu
This is the .java for my menu
Basically, I want the "@+id/Button01" to take me to:
FDIC: Failed Bank List
I have another xml/.java that sends me to that page. I just don't know how to get from where I am using the onClick method to take me to the page.
If I am able to send the user to the webpage from my MenuActivity.java page, you can ignore what is below this.
This is the other xml/.java that just takes you to the webpage, I wasn't sure if I had to send(from button click) the user to this, then this takes them to webpage.
Webpage XML
Webpage .Java
Any and all help is appreciated, I know it will be frustrating to explain something that I should already know but I am self-teaching myself this for an internship and had very little java experience and no android sdk experience and start a few weeks ago.
Thanks again
Siggi
The current problem I am having is trying to use the buttons on my menu page to open a webpage. There are four buttons on the menu, each will open a different webpage when clicked.
If I could just get an example to open up one of them I could easily figure out the others.
Do I need to create a new xml/.java for each of the buttons?
This is the xml for my menu
HTML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="wrap_content" android:background="@android:color/white"><RelativeLayout android:layout_below="@+id/TextView01" android:id="@+id/RelativeLayout02" android:layout_height="fill_parent" android:layout_width="fill_parent"></RelativeLayout><RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="@color/menubg"><Button android:id="@+id/Button01" android:text="@string/failedbanklist" android:clickable="true" android:layout_below="@+id/TextView01" android:layout_centerHorizontal="true" android:layout_marginLeft="50px" android:layout_marginRight="0px" android:fadeScrollbars="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="25px" android:textColor="@color/loadtxt" android:textSize="6pt" android:textStyle="normal|bold" android:typeface="serif" android:height="25px"></Button><Button android:id="@+id/Button02" android:text="@string/pressrls" android:layout_below="@+id/Button01" android:layout_centerHorizontal="true" android:layout_width="fill_parent" android:layout_marginLeft="50px" android:clickable="true" android:layout_height="wrap_content" android:layout_marginRight="0px" android:fadeScrollbars="true" android:height="25px" android:textSize="6pt" android:layout_marginBottom="25px" android:layout_marginTop="25px" android:textColor="@color/loadtxt" android:textStyle="normal|bold" android:typeface="serif"></Button><Button android:id="@+id/Button03" android:text="@string/helpfrm" android:layout_below="@+id/Button02" android:layout_centerHorizontal="true" android:layout_marginLeft="50px" android:clickable="true" android:layout_height="wrap_content" android:layout_marginRight="0px" android:fadeScrollbars="true" android:height="25px" android:textSize="6pt" android:textColor="@color/loadtxt" android:layout_width="fill_parent" android:layout_marginBottom="25px" android:textStyle="normal|bold" android:typeface="serif"></Button><Button android:id="@+id/Button04" android:layout_height="wrap_content" android:text="@string/btn4" android:layout_width="fill_parent" android:layout_marginLeft="50px" android:layout_centerHorizontal="true" android:layout_below="@+id/Button03" android:textColor="@color/loadtxt" android:textSize="6pt" android:layout_marginBottom="25px" android:typeface="serif" android:textStyle="normal|bold" android:clickable="true" android:fadeScrollbars="true" android:height="25px"></Button><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:id="@+id/TextView02" android:layout_below="@+id/Button04" android:text="@string/txt3" android:textColor="@android:color/black"></TextView><TextView android:id="@+id/TextView01" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerInParent="true" android:text="@string/mnuttl" android:textColor="@color/bkk" android:textStyle="bold" android:textSize="21pt" android:typeface="serif" android:layout_above="@+id/RelativeLayout02" android:layout_width="fill_parent" android:gravity="center" android:background="@android:color/white"></TextView><ImageView android:id="@+id/ImageView01" android:src="@drawable/rkwimagesmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="12px" android:paddingLeft="6px"></ImageView><ImageView android:id="@+id/ImageView02" android:paddingRight="6px" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:paddingTop="14px" android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/rkwimagesmall"></ImageView>
</RelativeLayout>
</LinearLayout>
This is the .java for my menu
Code:
package android.bankclosures;
import android.app.Activity;
import android.os.Bundle;
public class MenuActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
}
}
Basically, I want the "@+id/Button01" to take me to:
FDIC: Failed Bank List
I have another xml/.java that sends me to that page. I just don't know how to get from where I am using the onClick method to take me to the page.
If I am able to send the user to the webpage from my MenuActivity.java page, you can ignore what is below this.
This is the other xml/.java that just takes you to the webpage, I wasn't sure if I had to send(from button click) the user to this, then this takes them to webpage.
Webpage XML
Code:
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Webpage .Java
Code:
package android.bankclosures;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class Clsdbanks extends Activity {
WebView mWebView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.clsdbanks);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.fdic.gov/bank/individual/failed/banklist.html");
class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
mWebView.setWebViewClient(new HelloWebViewClient());
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
mWebView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
Any and all help is appreciated, I know it will be frustrating to explain something that I should already know but I am self-teaching myself this for an internship and had very little java experience and no android sdk experience and start a few weeks ago.
Thanks again
Siggi