我有一個簡單的消息應用程序,它獲取editText框的文本並將其發送到服務器。我想要做的就是當文本發送到服務器時,我想讓editText框重置。OnClick方法殺死Android應用程序
這裏是我的代碼工作,但,它不復位EDITTEXT框:
public void sendMessage(View v) {
Editable messagetext;
messagetext = message.getText();
final SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
username = prefs.getString("username", "null");
where = prefs.getString("chat", "null");
message = (EditText) findViewById(R.id.inptbox);
function = new Functions();
response = function
.sendMessage(username, where, messagetext.toString());
}
如果我添加一行代碼,以恢復我的應用程序死框:
public void sendMessage(View v) {
Editable messagetext;
messagetext = message.getText();
message.setText("");
final SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
username = prefs.getString("username", "null");
where = prefs.getString("chat", "null");
message = (EditText) findViewById(R.id.inptbox);
function = new Functions();
response = function
.sendMessage(username, where, messagetext.toString());
}
的錯誤,我得到(多多包涵,我沒那麼好logcat的)是:
E/AndroidRuntime(7207): java.lang.IllegalStateException: Could not execute method of the activity
全局變量列表:
String username = "";
Functions function;
EditText message;
String response = "";
String where = "";
String inboxx;
你可以發佈紅色文本的整個logcat錯誤日誌。 – 2012-04-24 23:29:56
什麼類型是'消息'? – 2012-04-24 23:31:11
在我的問題中更新。 「全局變量列表」 – EGHDK 2012-04-24 23:53:00