20150629_Andriod_06_插入_删除_弹出式操作数据
Fr_06_view_s6 --> activity_f6_insert
--> activity_f7__delete
************************************************************************
package com.example.ht;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;
import java.io.IOException;
//////////////////////////
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
//import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
//////////////////////////
public class Fr_06_view_s6 extends ActionBarActivity {
//////////////////////////
private Button btn2;
private Button btn3;
private ListView listView;
private SimpleAdapter adapter;
private String str_del;
private String str_insert1,str_insert2,str_insert5,str_insert6;
//////////////////////////
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fr_06_view_s6);
//////////////////////////
btn2 = (Button) findViewById(R.id.fr_s6_btn2);
btn3 = (Button) findViewById(R.id.fr_s6_btn3);
btn2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
hideButton(true);
setAddDialog();
}
});
btn3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
hideButton(true);
setDeleteDialog();
}
});
/////////////////////////
}
////////////////
/**
* 设置弹出删除对话框
*/
private void setDeleteDialog() {
final Dialog dialog = new Dialog(Fr_06_view_s6.this);
//dialog.setContentView(R.layout.dialog_delete);
dialog.setContentView(R.layout.activity_f7__delete);
dialog.setTitle("输入想要删除的人员ID");
Window dialogWindow = dialog.getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
dialogWindow.setGravity(Gravity.CENTER);
dialogWindow.setAttributes(lp);
//final EditText cNoEditText = (EditText) dialog.findViewById(R.id.editText1);
final EditText edit_del = (EditText) dialog.findViewById(R.id.editText_del);
Button btnConfirm = (Button) dialog.findViewById(R.id.button1);
Button btnCancel = (Button) dialog.findViewById(R.id.button2);
btnConfirm.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//dbUtil.deleteCargoInfo(cNoEditText.getText().toString());
dialog.dismiss();
hideButton(false);
////////新线程////////
str_del = edit_del.getText().toString().trim();
//if ("".equals(str_del) || str_del.length() < 7) {
if ("".equals(str_del) || str_del.trim() == "您输入为空")
{
//edit_del.setText("您输入为空");
//edit_del.requestFocus();
//edit_del.setText("");
Toast.makeText(Fr_06_view_s6.this, "您输入为空", Toast.LENGTH_SHORT).show();
return;
}
else
{
initView();
}
//////////////////
//Toast.makeText(MainActivity.this, "成功删除数据", Toast.LENGTH_SHORT).show();
//Toast.makeText(Fr_06_view_s6.this, "成功删除数据", Toast.LENGTH_SHORT).show();
//Toast.makeText(Fr_06_view_s6.this, str_del, Toast.LENGTH_SHORT).show();
}
});
btnCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
hideButton(false);
}
});
dialog.show();
}
///////delete ws/////////
///////delete ws/////////
///////delete ws/////////
private void initView()
{
String phone = str_del;
getRemoteInfo(str_del);
}
//
public void getRemoteInfo(final String phone) {
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
// 命名空间
String nameSpace = "http://tempuri.org/";
// 调用方法的名称
//String methodName = "selectAllCargoInfor";
String methodName = "deleteCargoInfo";
// EndPoint
String endPoint = "http://192.168.1.91:8028/an_sql_test1.asmx";
// SOAP Action
// String soapAction = "http://192.168.1.91:8028/an_sql_test1.asmx/selectAllCargoInfor";
String soapAction = "http://192.168.1.91:8028/an_sql_test1.asmx/deleteCargoInfo";
// 指定WebService的命名空间和调用方法
SoapObject soapObject = new SoapObject(nameSpace, methodName);
// 设置需要调用WebService接口的两个参数mobileCode UserId
//soapObject.addProperty("Ts_01", "");
soapObject.addProperty("Ts_01", str_del);
// 生成调用WebService方法调用的soap信息,并且指定Soap版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER12);
envelope.bodyOut = soapObject;
// 是否调用DotNet开发的WebService
envelope.dotNet = true;
envelope.setOutputSoapObject(soapObject);
HttpTransportSE transport = new HttpTransportSE(endPoint);
try {
transport.call(soapAction, envelope);
} catch (IOException e) {
//} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// 获取返回的数据
SoapObject object = (SoapObject) envelope.bodyIn;
// 获取返回的结果
String result = object.getProperty(0).toString();
Message message = handler.obtainMessage();
message.obj = result;
handler.sendMessage(message);
/////////
}
}).start();
}
private Handler handler = new Handler(){
public void handleMessage(android.os.Message msg) {
// 将WebService得到的结果返回给TextView
//tv_result.setText(msg.obj.toString());
String str_1;
str_1 = msg.obj.toString();
//如果要返回是否成功,应该再添加一组查询, 布尔类型。
//Toast.makeText(Fr_06_view_s6.this, str_1, Toast.LENGTH_SHORT).show();
Toast.makeText(Fr_06_view_s6.this, "成功删除数据", Toast.LENGTH_SHORT).show();
};
};
///////delete ws/////////
///////delete ws/////////
///////delete ws/////////
/**
* 设置弹出添加对话框
*/
private void setAddDialog() {
//final Dialog dialog = new Dialog(MainActivity.this);
final Dialog dialog = new Dialog(Fr_06_view_s6.this);
//dialog.setContentView(R.layout.dialog_add);
dialog.setContentView(R.layout.activity_f6_insert);
dialog.setTitle("输入添加的货物的信息");
Window dialogWindow = dialog.getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
dialogWindow.setGravity(Gravity.CENTER);
dialogWindow.setAttributes(lp);
final EditText insert_text1 = (EditText) dialog.findViewById(R.id.editText1);
final EditText insert_text2 = (EditText) dialog.findViewById(R.id.editText2);
final EditText insert_text5 = (EditText) dialog.findViewById(R.id.EditText5);
final EditText insert_text6 = (EditText) dialog.findViewById(R.id.EditText6);
Button btnConfirm = (Button) dialog.findViewById(R.id.button1);
Button btnCancel = (Button) dialog.findViewById(R.id.button2);
btnConfirm.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//dbUtil.insertCargoInfo(cNameEditText.getText().toString(), cNumEditText.getText().toString());
dialog.dismiss();
hideButton(false);
////////新线程////////
str_insert1 = insert_text1.getText().toString().trim();
str_insert2 = insert_text2.getText().toString().trim();
str_insert5 = insert_text5.getText().toString().trim();
str_insert6 = insert_text6.getText().toString().trim();
//if ("".equals(str_del) || str_del.length() < 7) {
if ("".equals(str_insert1) || str_insert1.trim() == "您输入为空")
{
//edit_del.setText("您输入为空");
//edit_del.requestFocus();
//edit_del.setText("");
Toast.makeText(Fr_06_view_s6.this, "您输入为空", Toast.LENGTH_SHORT).show();
return;
}
else
{
insert_into();
}
////////新线程////////
//Toast.makeText(MainActivity.this, "成功添加数据", Toast.LENGTH_SHORT).show();
//Toast.makeText(Fr_06_view_s6.this, "成功添加数据", Toast.LENGTH_SHORT).show();
}
});
btnCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
hideButton(false);
}
});
dialog.show();
}
///////insert_ws/////////
///////insert_ws/////////
///////insert_ws/////////
private void insert_into()
{
insert_into_data();
}
//
public void insert_into_data() {
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
// 命名空间
String nameSpace = "http://tempuri.org/";
// 调用方法的名称
//String methodName = "selectAllCargoInfor";
String methodName = "insertCargoInfo";
// EndPoint
String endPoint = "http://192.168.1.91:8028/an_sql_test1.asmx";
// SOAP Action
// String soapAction = "http://192.168.1.91:8028/an_sql_test1.asmx/selectAllCargoInfor";
String soapAction = "http://192.168.1.91:8028/an_sql_test1.asmx/insertCargoInfo";
// 指定WebService的命名空间和调用方法
SoapObject soapObject = new SoapObject(nameSpace, methodName);
// 设置需要调用WebService接口的两个参数mobileCode UserId
//soapObject.addProperty("Ts_01", "");
soapObject.addProperty("Ts_01", str_insert1);
soapObject.addProperty("Ts_02", str_insert2);
soapObject.addProperty("Ts_03", str_insert5);
soapObject.addProperty("Ts_06", str_insert6);
// 生成调用WebService方法调用的soap信息,并且指定Soap版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER12);
envelope.bodyOut = soapObject;
// 是否调用DotNet开发的WebService
envelope.dotNet = true;
envelope.setOutputSoapObject(soapObject);
HttpTransportSE transport = new HttpTransportSE(endPoint);
try {
transport.call(soapAction, envelope);
} catch (IOException e) {
//} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// 获取返回的数据
SoapObject object = (SoapObject) envelope.bodyIn;
// 获取返回的结果
String result = object.getProperty(0).toString();
Message message = handler2.obtainMessage();
message.obj = result;
handler2.sendMessage(message);
/////////
}
}).start();
}
private Handler handler2 = new Handler(){
public void handleMessage(android.os.Message msg) {
// 将WebService得到的结果返回给TextView
//tv_result.setText(msg.obj.toString());
String str_1;
str_1 = msg.obj.toString();
//如果要返回是否成功,应该再添加一组查询, 布尔类型。
//Toast.makeText(Fr_06_view_s6.this, str_1, Toast.LENGTH_SHORT).show();
Toast.makeText(Fr_06_view_s6.this, str_1.toString().trim(), Toast.LENGTH_SHORT).show();
};
};
///////insert_ws/////////
///////insert_ws/////////
///////insert_ws/////////
/**
* 设置button的可见性
*/
private void hideButton(boolean result) {
if (result) {
btn2.setVisibility(View.GONE);
btn3.setVisibility(View.GONE);
} else {
btn2.setVisibility(View.VISIBLE);
btn3.setVisibility(View.VISIBLE);
}
}
/**
* 返回按钮的重写
*/
@Override
public void onBackPressed()
{
if (listView.getVisibility() == View.VISIBLE) {
listView.setVisibility(View.GONE);
hideButton(false);
}else {
//MainActivity.this.finish();
Fr_06_view_s6.this.finish();
}
}
/////////////
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.fr_06_view_s6, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
************************************************************************
************************************************************************
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.ht.Fr_06_view_s6" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Fr_Form_06" />
<Button
android:id="@+id/fr_s6_btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="133dp"
android:text="@string/btn2" />
<Button
android:id="@+id/fr_s6_btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/fr_s6_btn2"
android:layout_centerHorizontal="true"
android:text="@string/btn3" />
</RelativeLayout>
************************************************************************
************************************************************************
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.ht.F7_Delete" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/F7_Form" />
<EditText
android:id="@+id/editText_del"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout1"
android:layout_below="@+id/textView1"
android:layout_marginTop="66dp"
android:ems="10"
android:hint="@string/delete_hint" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentBottom="true"
android:layout_marginBottom="47dp"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:text="@string/confirm" />
<Button
android:id="@+id/button2"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_marginLeft="40dip"
android:text="@string/cancel" />
</LinearLayout>
</RelativeLayout>
************************************************************************
************************************************************************
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.ht.F6_insert" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/F6_Form" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText2"
android:layout_alignParentBottom="true"
android:layout_marginBottom="54dp"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:text="@string/confirm" />
<Button
android:id="@+id/button2"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_marginLeft="40dip"
android:text="@string/cancel" />
</LinearLayout>
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText2"
android:layout_below="@+id/textView1"
android:layout_marginTop="30dp"
android:ems="10"
android:hint="@string/add_hint1" />
<EditText
android:id="@+id/editText2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/EditText5"
android:layout_below="@+id/editText1"
android:ems="10"
android:hint="@string/add_hint2"
android:inputType="number" />
<EditText
android:id="@+id/EditText5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/EditText6"
android:layout_below="@+id/editText2"
android:ems="10"
android:hint="@string/add_hint5" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/EditText6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/EditText5"
android:ems="10"
android:hint="@string/add_hint6"
android:inputType="number" />
</RelativeLayout>
************************************************************************
************************************************************************
20150629_Andriod_06_插入_删除_弹出式操作数据的更多相关文章
- JS框架_(JQuery.js)Tooltip弹出式按钮插件
百度云盘 传送门 密码:7eh5 弹出式按钮效果 <!DOCTYPE html> <html > <head> <meta charset="UTF ...
- web开发实战--弹出式富文本编辑器的实现思路和踩过的坑
前言: 和弟弟合作, 一起整了个智慧屋的小web站点, 里面包含了很多经典的智力和推理题. 其实该站点从技术层面来分析的话, 也算一个信息发布站点. 因此在该网站的后台运营中, 富文本的编辑器显得尤为 ...
- 2019-9-25-如何让-USB-设备不显示安全删除硬件弹出选项
title author date CreateTime categories 如何让 USB 设备不显示安全删除硬件弹出选项 lindexi 2019-09-25 11:58:19 +0800 20 ...
- web全栈开发之网站开发二(弹出式登录注册框前端实现-类腾讯)
这次给大家分享的是目前很多网站中流行的弹出式登录框,如下面的腾讯网登录界面,采用弹出式登录的好处是大大提升了网站的用户体验和交互性,用户不用重新跳转到指定的页面就能登录,非常方便 先来个演示地址 要实 ...
- asp.net 弹出式日历控件 选择日期 Calendar控件
原文地址:asp.net 弹出式日历控件 选择日期 Calendar控件 作者:逸苡 html代码: <%@ Page Language="C#" CodeFile=&quo ...
- PropertyGrid—为复杂属性提供下拉式编辑框和弹出式编辑框
零.引言 PropertyGrid中我们经常看到一些下拉式的编辑方式(Color属性)和弹出式编辑框(字体),这些都是为一些复杂的属性提供的编辑方式,本文主要说明如何实现这样的编辑方式. 一.为属性提 ...
- ZH奶酪:Ionic中(弹出式窗口)的$ionicModal使用方法
Ionic中[弹出式窗口]有两种(如下图所示),$ionicModal和$ionicPopup; $ionicModal是完整的页面: $ionicPopup是(Dialog)对话框样式的,直接用Ja ...
- php弹出式登录窗口并获得登录后返回值
一款bootstrap样式结合php制作的弹出式登录窗口,输入用户名和密码后,ajax传参给后台,并获得登录后返回值. hwLayer+ajax弹出登录框 $(function() { $('#for ...
- 让小区运营再智能一点,EasyRadius正式向WayOs用户提供到期弹出式提示充值页面
其实一直没向用户提供到期弹出式页面,主要是给VIP群的用户一点优越感,随着这次EasyRadius的更新,海哥就免费向普通easyRadius用户提供这两个模板下载. 有些人会问,什么样的模板.有什么 ...
随机推荐
- docker offical docs:Working with Containers
enough ---------------------------------------------------------------------------------- Working wi ...
- linux:习惯
1>.系统里面必须最少有两个账号,一个root,一个普通账户; 2>.平时登录系统均使用普通账户登录,除非需要配置或者执行特殊命令才切换至root; 3>.linux系统下严格区分大 ...
- 【转】DataSource高级应用
我们知道 DataSource能提供最高性能的对数据库的并发访问,但是,对DataSource的引用,也还有很多知识要弄清楚,获取Connection的方式是数据库性能最相关的技术,而对DataSou ...
- 强连通+二分匹配(hdu4685 Prince and Princess)
Prince and Princess Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Othe ...
- Extjs布局
今天我来总结一下extjs下面的各种布局,不仅是为了给自己做笔记,同时,也希望让刚刚接触extjs的朋友们快速的了解下,大神就不用看了.废话不多说,开始布局的讲解. (以下代码都可以直接在javasc ...
- CCF真题之相反数
201403-1 问题描述 有 N 个非零且各不相同的整数.请你编一个程序求出它们中有多少对相反数(a 和 -a 为一对相反数). 输入格式 第一行包含一个正整数 N.(1 ≤ N ≤ 500). ...
- spark读取hdfs数据本地性异常
在分布式计算中,为了提高计算速度,数据本地性是其中重要的一环. 不过有时候它同样也会带来一些问题. 一.问题描述 在分布式计算中,大多数情况下要做到移动计算而非移动数据,所以数据本地性尤其重要,因此我 ...
- 关于 VS 无法转到定义和无法转到使用的问题
今天提交完代码以后突然发现 咦 怎么F12 .点击右键的方法都不能转到定义了 转到引用 也提示 没有发现 重启VS 还是不行 .去找王晓 他也不清楚(其实我知道 他应该也不清楚 ...
- getResource().getPath()返回的路径空格变成了 %20
this.getClass().getResource(“/”).getPath()使用者方法查看文件在服务器上的地址,但是地址中的空格会被转化为%20. 解决办法1: URI uri = new U ...
- [OrangePi] If you are using an older image
Download scriptbin_kernel.tar.gz from Mega, unpack. Copy uImage_OPI-2 or uImage_OPI-PLUS (depending ...