package com.zb.sendtoweb; import com.zb.service.SendService; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity { private EditText titleTxt,timeTxt; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); titleTxt = (EditText)this.findViewById(R.id.title); timeTxt = (EditText)this.findViewById(R.id.time); } public void save(View view){ String title = titleTxt.getText().toString(); String time = timeTxt.getText().toString(); boolean flag; try { flag = SendService.add(title,time); System.out.println(flag "&&&&"); if(flag){ Toast.makeText(getApplicationContext(), "发送并保存成功", 1).show(); }else{ Toast.makeText(getApplicationContext(), "发送失败", 1).show(); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }
评论