我的代码是这样的,创建了一个构造函数。我想从 homepage.java 访问字符串到 login.php。但是android给了我一个错误“不允许访问构造函数”..我做错了吗?请帮忙。主页.java
public class HomePage extends Activity {
private Button clBtn;
private Button bcBtn;
private Button atBtn;
public String ip="";
HomePage()
{
this.ip = "http://111.111.11.1/sp/";
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_page);
}
}
登录.java
public class Login extends Activity {
private EditText etFacNo;
private EditText etPassword;
private Button loginBtn;
HomePage getIP = new HomePage();
String url = getIP.ip;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_page);
.
.
.
.
.
HttpClient httpclient = new DefaultHttpClient();
HttpPost request = new HttpPost(url+"loginteacher.php");
}
}