我有一个问题要快速解决:) 我有这段代码:
loginBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HttpRequest hr = new HttpRequest();
String response = hr.LoginRequest(emailText.getText().toString(), pwdText.getText().toString());
res.setText(response);
res.setVisibility(0);
if(response.equals("pr_code_0101")) {
Login.this.startActivity(bcard_intent);
}
}
});
startActivity 失败,我的应用程序崩溃,我遇到了问题:它是带有 LoginRequest 的 HttpRequest,它是我创建的自定义类,如果我删除这 2 行代码,活动就会开始......
Http的代码
public String LoginRequest(String email, String password)
{
List<NameValuePair> nvp = new ArrayList<NameValuePair>(3);
nvp.add(new BasicNameValuePair("email", email));
nvp.add(new BasicNameValuePair("password", password));
nvp.add(new BasicNameValuePair("hash_app", hash_code));
return Set("******/loginrequest.php", nvp);
}
public String Set(String url,List<NameValuePair> list)
{
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
try {
httpPost.setEntity(new UrlEncodedFormEntity(list));
HttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null)
{
builder.append(line);
}
reader.close();
content.close();
}
catch (ClientProtocolException e) {
return e.toString();
}
catch (IOException e) {
return e.toString();
}
return builder.toString();
}
我该如何解决我的问题??
这里是logcat:
01-20 11:25:42.824: E/AndroidRuntime(274): java.lang.RuntimeException: Unable to start activity ComponentInfo{name.printernet.app/name.printernet.app.BCard}: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>