[Java]杂项

create: 2019-01-03 | update:2019-01-03

JAVAEE

package com.jinghong.msgboard;
import com.jinghong.msgboard.AsynTaskUtil.AsynNetUtils;
import com.jinghong.msgboard.AsynTaskUtil.AsynNetUtils.Callback;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class AddItemActivity extends Activity {
	private EditText etMsgPerson;
	private EditText etMsgContent;
	private Button btSubmit;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_add_item);
		etMsgPerson=(EditText)findViewById(R.id.edit_name);
		etMsgContent=(EditText)findViewById(R.id.edit_content);
		btSubmit=(Button)findViewById(R.id.btn_submit);
		btSubmit.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO 自动生成的方法存根
				String MsgPerson=etMsgPerson.getText().toString().replace("\n", ";");
				String MsgContent=etMsgContent.getText().toString().replace("\n", ";");
				if(!MsgPerson.equals("")&&!MsgContent.equals("")){
					//PostUtil.AddItem(MsgPerson, MsgContent,AddItemActivity.this, MsgBoardUtil.getTime());
					AsynNetUtils.post("http://101.132.122.143:8080/MsgBoard/PostServlet", "method=addindex&msgperson="+MsgPerson+"&msgcnt="+MsgContent+"&posttime="+MsgBoardUtil.getTime(), new Callback() {
						@Override
						public void onResponse(String response) {
							// TODO Auto-generated method stub
						}
					});
					Intent intent = new Intent(AddItemActivity.this,MainActivity.class);
					startActivity(intent);
					finish();
				}else{
					Toast.makeText(AddItemActivity.this, "留言人姓名或留言内容不能为空!", Toast.LENGTH_SHORT).show();
				}
			}
		});
	}
}