This is my NetABC java file in my project. Here I define multiple listeners for buttons in my main.xml layout. Everyone of those listeners work fine.
When I push the StatusButton (defined few scrolls down), it takes me to my second layout: status.xml. In status.xml I have a few buttons. I would like to create listeners for them in NetABC.java aswell. Here's the problem: Whenever I make listeners in NetABC.java for buttons in main.xml, everthing works perfectly well. The second I create a listener for a button which is not residing in main.xml layout, but insted, let's say status.xml layout I get an error when trying to simulate on AVD.
The last listener is an example of a button not residing in main.xml but in status.xml. It's suppose to work as a back button, which takes me back from status.xml to main.xml. I define it the same way as any other button listener I have defined. By using the R.id.button etc.
Any chance anyone would know why a listener defined for a button not in main.xml creates an error? Any help much appreciated.
package com.netabc;
import com.netabc.R;
import android.app.Activity;
import android.os.Bundle;
import android.content.DialogInterface;
import android.widget.Button;
import android.app.AlertDialog;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.widget.EditText;
import android.widget.TextView;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
public class NetABC extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//TextView myTextView = (TextView) findViewById( .IPText1);
//myTextView.setText(ip);
// Sett Klikk Lytter SSID Knapp
Button SSIDButton = (Button) findViewById(R.id.SSIDButton);
SSIDButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
// Sett Klikk Lytter IP Knapp
Button IPButton = (Button) findViewById(R.id.IPButton);
IPButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
// Sett Klikk Lytter Subnetmaske Knapp
Button SubnetmaskeButton = (Button) findViewById(R.id.SubnetmaskeButton);
SubnetmaskeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
// Sett Klikk Lytter Default Gateway Knapp
Button DefaultGatewayButton = (Button) findViewById(R.id.DefaultGatewayButton);
DefaultGatewayButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
// Sett Klikk Lytter Nettverk Status Knapp
Button StatusButton = (Button) findViewById(R.id.Nettverk_StatusButton);
StatusButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setContentView(R.layout.status);
}
});
// Sett Klikk Lytter Nettverk Ekstra Knapp
Button EkstraButton = (Button) findViewById(R.id.Nettverk_EkstraButton);
EkstraButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setContentView(R.layout.ekstra);
}
});
//Sett Klikk Lytter Back Knapp
Button BackButton1 = (Button) findViewById(R.id.Signal_StyrkeButton);
BackButton1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setContentView(R.layout.main);
}
});
};
}