我該如何讓我的應用程序繼續檢查?通過含義保持檢查是否有在那裏如何不斷檢查android中的文本更改事件?
String str1, str2;
str1 = word.getText().toString();
str2 = answer.getText().toString();
if(!(str1.equals("")) && !(str2.equals("")))
{
teach.setEnabled(true);
}
else
{
teach.setEnabled(false);
}
這裏是哪裏,我會放在固定的代碼,使得它檢查和每一件事情我的Java代碼文本?請幫忙!
public class TeachmeDialog extends Activity implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.teachme);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Button teach = (Button)findViewById(R.id.btn_teach_send);
teach.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.btn_teach_send:
{
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://monaiz.net/get.php");
String responseStr = "";
try {
TextView word = (TextView)findViewById(R.id.tv_teach_request);
TextView answer = (TextView)findViewById(R.id.tv_teach_response);
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
nameValuePairs.add(new BasicNameValuePair("word", word.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("answer", answer.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("action", "teach"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
responseStr = EntityUtils.toString(entity);
} catch (Exception e) {
// TODO Auto-generated catch block
}
if(responseStr.equals("ok"))
{
Toast.makeText(getApplicationContext(), "Poco just learned a new word!", Toast.LENGTH_LONG).show();
try {
this.finish();
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
}
檢查裏面是否有文字?但是哪裏?你到底想做什麼? – 2012-03-20 06:48:57
有問題的問題。請說清楚。發佈代碼不會**發佈問題。 – JoxTraex 2012-03-20 06:57:40
可能的重複問題 - http://stackoverflow.com/questions/3696082/how-to-schedule-my-android-app-to-do-something-every-hour – 2012-03-20 06:59:39