您将如何为这样的图像制作 java 代码?
那是来自Android模拟器。我正在尝试将发布数据信息输入每个插槽并将信息上传到 MySQL 数据库。
这是到目前为止的代码:
public class Registration extends Activity {
TextView Taccount,Tpassword,Tfirst,Tlast,Temail,Tlocation,Tdescription;
EditText Eaccount,Epassword,Efirst,Elast,Eemail,Elocation,Edescription;
Button btnCreate;
String page="";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cappuccino);
btnCreate = (Button) findViewById(R.id.btnGen);
Taccount = (TextView) findViewById(R.id.txtAccountID);
Eaccount = (EditText) findViewById(R.id.editAccountID);
Tpassword = (TextView) findViewById(R.id.txtPassword);
Epassword = (EditText) findViewById(R.id.editPassword);
Tfirst = (TextView) findViewById(R.id.txtFirst);
Efirst = (EditText) findViewById(R.id.editFirst);
Tlast = (TextView) findViewById(R.id.txtLast);
Elast = (EditText) findViewById(R.id.editLast);
Temail = (TextView) findViewById(R.id.txtEmail);
Eemail = (EditText) findViewById(R.id.editEmail);
Tlocation = (TextView) findViewById(R.id.txtLocation);
Elocation = (EditText) findViewById(R.id.editLocation);
Tdescription = (TextView) findViewById(R.id.txtDescription);
Edescription = (EditText) findViewById(R.id.editDescription);
btnCreate.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
examineJSONFile();
}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_cappuccino, menu);
return true;
}
void examineJSONFile()
{
try
{
JSONObject object=new JSONObject();
object.put("Account ID", Eaccount.getText());
object.put("Password", Epassword.getText());
object.put("First Name", Efirst.getText());
object.put("Last Name", Elast.getText());
object.put("Email", Eemail.getText());
object.put("Location", Elocation.getText());
object.put("Description", Edescription.getText());
String str=object.toString();
executeHttpPost(str);
Log.i("JsonString :", str);
Toast.makeText(this, "Json Objects are : " + str,Toast.LENGTH_LONG).show();
}
catch (Exception je)
{
}
}
public void executeHttpPost(String string) throws Exception
{
//This method for HttpConnection
try
{
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost("http://localhost:8080/example/database/Cappuccino.sql");
List<NameValuePair> value=new ArrayList<NameValuePair>();
value.add(new BasicNameValuePair("Account ID",string));
UrlEncodedFormEntity entity=new UrlEncodedFormEntity(value);
request.setEntity(entity);
client.execute(request);
System.out.println("after sending :"+request.toString());
}
catch(Exception e) {System.out.println("Exp="+e);
}
}
}
提前致谢!