- 读取csv文件知识,因为csv文件是以“,”号分割的,所以用这个来划分
package com.pressuretran.prodect.csv;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class readCsv
{
private String fileName = null;
private BufferedReader br = null;
private List<String> list = new ArrayList<String>();
<span style="white-space:pre"> </span>public readCsv() {
<span style="white-space:pre"> </span>这个是构造,空的
}
public readCsv(String fileName) throws Exception {
this.fileName = fileName;
//br = new BufferedReader(new FileReader(fileName));
br=new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "GBK"));//因为要转换格式,防止乱码
String stemp;
while ((stemp = br.readLine()) != null) {
list.add(stemp);
}
}
public List getList() {
return list;
}
public int getRowNum() {
return list.size();
}
public int getColNum() {
if (!list.toString().equals("[]")) {
if (list.get(0).toString().contains(",")) {
return list.get(0).toString().split(",").length;
} else if (list.get(0).toString().trim().length() != 0) {
return 1;
} else {
return 0;
}
} else {
return 0;
}
}
public String getRow(int index) {
if (this.list.size() != 0) {
return (String) list.get(index);
} else {
return null;
}
}
public String getCol(int index) {
if (this.getColNum() == 0) {
return null;
}
StringBuffer sb = new StringBuffer();
String tmp = null;
int colnum = this.getColNum();
if (colnum > 1) {
for (Iterator it = list.iterator(); it.hasNext();) {
tmp = it.next().toString();
sb = sb.append(tmp.split(",")[index] + ",");
}
} else {
for (Iterator it = list.iterator(); it.hasNext();) {
tmp = it.next().toString();
sb = sb.append(tmp + ",");
}
}
String str = new String(sb.toString());
str = str.substring(0, str.length() - 1);
return str;
}
public String getString(int row, int col) {
String temp = null;
int colnum = this.getColNum();
if (colnum > 1) {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span> temp = list.get(row).toString().split(",")[col];
<span style="white-space:pre"> </span>
} else if(colnum == 1){
temp = list.get(row).toString();
} else {
temp = null;
}
return temp;
}
public String[] getStringFour(int row) {
String[] temp = null;
int colnum = this.getColNum();
System.out.println("colunm"+colnum);
if (colnum > 1) {
temp = list.get(row).toString().split(",");
} else if(colnum == 1){
//temp = list.get(row);
} else {
temp = null;
}
return temp;
}
public void CsvClose()throws Exception{
this.br.close();
}
}
- db转化为.csv文件
package com.pressuretran.prodect.csv;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import android.content.Context;
import android.database.Cursor;
import android.os.Environment;
import android.util.Log;
public class dbToDataCsv
{
private Context mcontext;
private Cursor c;
private String fileName;
private String csvName;
public dbToDataCsv(Context context,Cursor cursor,String fileName)
{
this.mcontext=context;
this.c=cursor;
this.fileName=fileName;
this.csvName = csvName;
}
public void ExportToDataCSV(String csvName)
{
int rowCount = 0;
int colCount = 0;
OutputStreamWriter fw;
BufferedWriter bfw;
//File saveFile = new File(csvName, fileName);
/*File saveFile = new File(path, fileName);*/
try
{
File saveFile1 = new File(csvName,fileName);
FileOutputStream saveFile=new FileOutputStream(saveFile1);
rowCount = c.getCount();
colCount = c.getColumnCount();
//fw = new FileWriter(saveFile);
fw=new OutputStreamWriter(saveFile,"gbk");
//new InputStreamReader(new FileInputStream(fileName), "gbk")
bfw = new BufferedWriter(fw);
if (rowCount==0)
{
c.moveToFirst();
for (int i = 1; i < colCount; i++)
{
if (i != colCount - 1)
bfw.write(c.getColumnName(i) + ',');
else
bfw.write(c.getColumnName(i));
//System.out.println(c.getColumnName(i)+"1");
}
}
if (rowCount > 0)
{
c.moveToFirst();
/*//
for (int i = 1; i < colCount; i++)
{
if (i != colCount - 1)
bfw.write(c.getColumnName(i) + ',');
else
bfw.write(c.getColumnName(i));
}
//
bfw.newLine();*/
for (int i = 0; i < rowCount; i++)
{
c.moveToPosition(i);
// Toast.LENGTH_SHORT).show();
for (int j = 1; j < colCount; j++)
{
if (j != colCount )
bfw.write(c.getString(j) + ',');
else
bfw.write(c.getString(j));
}
bfw.newLine();
}
}
bfw.flush();
bfw.close();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} finally
{
c.close();
}
}
}
- 本软件的入口函数,也就是第一级的菜单
package com.pressuretran.prodect.activity;
import java.util.Timer;
import java.util.TimerTask;
import com.pressuretran.prodect.R;
import com.pressuretran.prodect.sdcard.sdcard_entryFileManagerActivity;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class firstMenuActivity extends Activity {
/*
* lwn
* 主界面:显示8个按钮,甚至更多,采用gridView填充,可以动态更改
*/
private Button button_first_01;
private Button button_first_02;
private Button button_first_03;
private Button button_first_04;
private Button button_first_05;
private Button button_first_06;
private Button button_first_07;
private Button button_first_08;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first_menu_activity);
//setContentView(R.layout.aa);
init();
}
private void init()
{
button_first_01=(Button) findViewById(R.id.button_first_01);button_first_01.setOnClickListener(new buttonListener());
button_first_02=(Button) findViewById(R.id.button_first_02);button_first_02.setOnClickListener(new buttonListener());
button_first_03=(Button) findViewById(R.id.button_first_03);button_first_03.setOnClickListener(new buttonListener());
button_first_04=(Button) findViewById(R.id.button_first_04);button_first_04.setOnClickListener(new buttonListener());
button_first_05=(Button) findViewById(R.id.button_first_05);button_first_05.setOnClickListener(new buttonListener());
button_first_06=(Button) findViewById(R.id.button_first_06);button_first_06.setOnClickListener(new buttonListener());
button_first_07=(Button) findViewById(R.id.button_first_07);button_first_07.setOnClickListener(new buttonListener());
button_first_08=(Button) findViewById(R.id.button_first_08);button_first_08.setOnClickListener(new buttonListener());
}
private class buttonListener implements OnClickListener
{
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button_first_01:
Intent i1=new Intent(firstMenuActivity.this,twoMenuPressureActivity.class);
startActivity(i1);
firstMenuActivity.this.finish();//跳转对应的二级菜单之后此界面要消失
break;
case R.id.button_first_02:
Intent i2=new Intent(firstMenuActivity.this,twoMenuFlowMeterActivity.class);
startActivity(i2);
firstMenuActivity.this.finish();//跳转对应的二级菜单之后此界面要消失
break;
case R.id.button_first_03:
Intent i3=new Intent(firstMenuActivity.this,twoMenuMateriallevelmeterActivity.class);
startActivity(i3);
firstMenuActivity.this.finish();//跳转对应的二级菜单之后此界面要消失
break;
case R.id.button_first_04:
Intent i4=new Intent(firstMenuActivity.this,twoMenuCombustibleGasActivity.class);
startActivity(i4);
firstMenuActivity.this.finish();//跳转对应的二级菜单之后此界面要消失
break;
case R.id.button_first_05:
Intent i5=new Intent(firstMenuActivity.this,twoMenuTemperatureActivity.class);
startActivity(i5);
firstMenuActivity.this.finish();//跳转对应的二级菜单之后此界面要消失
break;
case R.id.button_first_06:
break;
case R.id.button_first_07:
break;
case R.id.button_first_08:
break;
default:
break;
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE,1,Menu.NONE,R.string.first_menu_daoru);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
Intent i= new Intent(firstMenuActivity.this,sdcard_entryFileManagerActivity.class);
startActivity(i);
firstMenuActivity.this.finish();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
/**
* 菜单、返回键响应
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode == KeyEvent.KEYCODE_BACK)
{
exitBy2Click(); //调用双击退出函数
}
return false;
}
/**
* 双击退出函数
*/
private static Boolean isExit = false;
private void exitBy2Click() {
Timer tExit = null;
if (isExit == false) {
isExit = true; // 准备退出
Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT).show();
tExit = new Timer();
tExit.schedule(new TimerTask() {
@Override
public void run() {
isExit = false; // 取消退出
}
}, 2000); // 如果2秒钟内没有按下返回键,则启动定时器取消掉刚才执行的任务
} else {
finish();
System.exit(0);
}
}
}
- 点击菜单按钮,会跳转到sdcard目录下找csv文件,并且读取,完事之后跳回来
package com.pressuretran.prodect.sdcard;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.pressuretran.prodect.R;
import com.pressuretran.prodect.activity.firstMenuActivity;
import com.pressuretran.prodect.activity.progressActivity;
import com.pressuretran.prodect.activity.twoMenuCombustibleGasActivity;
import com.pressuretran.prodect.csv.readCsv;
import com.pressuretran.prodect.sql.sqlDbHelper;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Environment;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
/*
* 此处是进入sdcard目录下面的product目录
* 然后单击确定就可以读取文件了
*/
public class sdcard_entryFileManagerActivity extends ListActivity {
private List<String> items = null; //每一个条目
private List<String> paths = null; //父路径
private String rootPath = "/sdcard/product"; //sdcard 目录
private String curPath = "/"; //
private TextView mPath;
public int Selectedposition=-1;
private BaseAdapter FileAdapter;
private boolean exstorageReadable=false;
private boolean exstorageWriteable=false;
String stringExtra ;
private int resultCode = 1;
private sqlDbHelper dbHelper;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
/*
* 进来获取权限,并且判断sdCard的权限
*/
requestWindowFeature(Window.FEATURE_NO_TITLE);
String state=Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state))
{
exstorageReadable=exstorageWriteable=true;
Toast.makeText(this, "sdCard可以正常使用", 1).show();
}else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state))
{
exstorageReadable=true;
exstorageWriteable=false;
Toast.makeText(this, "sdCard可读不可写", 1).show();
}else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state))
{
exstorageReadable=false;
exstorageWriteable=true;
Toast.makeText(this, "sdCard可写不可读", 1).show();
}
else {
exstorageReadable=exstorageWriteable=false;
Toast.makeText(this, "sdCard不可读写", 1).show();
}
setContentView(R.layout.sdcard_entryfileselect_activity);
//确定按钮
Button buttonConfirm = (Button) findViewById(R.id.entry_buttonConfirm);
buttonConfirm.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
readCsv();//读取完csv文件存到数据库中
/*
* 再转成小块存到每一个表
* 我先以一个字段查出来,然后插入到一个新表中
*/
//new一个类
// dbHelper.rawMyQuerySql("P2X系列");
System.out.println("lwn");
Intent i=new Intent(sdcard_entryFileManagerActivity.this,progressActivity.class);
startActivity(i);
System.out.println(dbHelper.rawMyQuerySeries());
dbHelper.close();
finish();
}
});
//取消按钮
Button buttonCancle = (Button) findViewById(R.id.entry_buttonCancle);
buttonCancle.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i=new Intent(sdcard_entryFileManagerActivity.this,firstMenuActivity.class);
startActivity(i);
finish();
}
});
mPath = (TextView) findViewById(R.id.mPath);//最上面的显示目录的textView
getFileDir(rootPath);//列出当前目录下的所有文件
dbHelper=new sqlDbHelper(this);
}
File file;
private void getFileDir(String filePath) {
mPath.setText(filePath);
items = new ArrayList<String>();
paths = new ArrayList<String>();
File f = new File(filePath);
File[] files = f.listFiles();
if (!filePath.equals(rootPath)) {
items.add("b1");
paths.add(rootPath);
items.add("b2");
paths.add(f.getParent());
}
if (files==null){
}else{
for (int i = 0; i < files.length; i++) {
file = files[i];
items.add(file.getName());
paths.add(file.getPath());
}
}
FileAdapter=new sdcard_entry_MyAdapter(this, items, paths,Selectedposition);
setListAdapter(FileAdapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// Selectedposition=position;
System.out.println("<<<<<<<<"+Selectedposition);
try {
File file = new File(paths.get(position));
if (file.isDirectory()) {
curPath = paths.get(position);
v.setBackgroundColor(Color.WHITE);
getFileDir(paths.get(position));
} else{
try
{
v.setSelected(true);
Selectedposition=position;
curPath = paths.get(position);
} catch (Exception e)
{
Toast.makeText(this, "sorry",1 ).show();
}
}
}catch (Exception e){
Toast.makeText(this, "sorry",1 ).show();
e.printStackTrace();
}
}
/*
* 4:读取csv文件的方法,顺便存入到数据库中
*/
public void readCsv()
{
readCsv util=null;
try
{
util=new readCsv(file.getPath());
} catch (Exception e)
{
// TODO: handle exception
}
int rowNum = util.getRowNum();//
int colNum = util.getColNum();//
System.out.println("行:" + rowNum);
System.out.println("列" + colNum);
ArrayList list =dbHelper.rawMyQuery();
System.out.println(list.size());
if (list.size()>0)
{
//就是说只要每次读取数据的时候先删除了原来有的如果有数据先删除
dbHelper.delete();
for (int i=0;i<rowNum;i++)
{
/*String string;
if (util.getStringFour(i).length>3)
{
string = util.getString(i, 3);
}else {
string=" ";
}*/
//insert(stringExtra ,util.getString(i, 0), util.getString(i, 1), util.getString(i, 2),string);
dbHelper.insertNong(util.getString(i, 0), util.getString(i, 1), util.getString(i, 2), util.getString(i, 3), util.getString(i, 4));
System.out.println(util.getString(i, 4));
}
}else {
for (int i=0;i<rowNum;i++)
{
/* String string;
if (util.getStringFour(i).length>3)
{
string = util.getString(i, 3);
}else {
string=" ";
}*/
dbHelper.insertNong(util.getString(i, 0), util.getString(i, 1), util.getString(i, 2), util.getString(i, 3), util.getString(i, 4));
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// TODO Auto-generated method stub
return super.onCreateOptionsMenu(menu);
}
//返回键的方法
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK) {
startActivity(new Intent(this,firstMenuActivity.class));
sdcard_entryFileManagerActivity.this.finish();
}
return false;
}
}
package com.pressuretran.prodect.sdcard;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.io.File;
import java.util.List;
import com.pressuretran.prodect.R;
public class sdcard_entry_MyAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private Bitmap mIcon1;
private Bitmap mIcon2;
private Bitmap mIcon3;
private Bitmap mIcon4;
private List<String> items;
private List<String> paths;
// public int selectedposition=com.example.FileExplorer.MyFileManagerActivity.Selectedposition;
public int selectedposition;
public sdcard_entry_MyAdapter(Context context, List<String> it, List<String> pa, int select){
this.selectedposition = select;
mInflater=LayoutInflater.from(context);
items=it;
paths=pa;
mIcon1=BitmapFactory.decodeResource(context.getResources(),R.drawable.sdcard_actuvity_entry_adapter_back01);
mIcon2=BitmapFactory.decodeResource(context.getResources(),R.drawable.sdcard_actuvity_entry_adapter_);
mIcon3=BitmapFactory.decodeResource(context.getResources(),R.drawable.sdcard_actuvity_entry_adapter_folder);
mIcon4=BitmapFactory.decodeResource(context.getResources(),R.drawable.sdcard_actuvity_entry_adapter_doc);
}
@Override
public int getCount() {
return items.size();
}
@Override
public Object getItem(int position) {
return items.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if(convertView==null){
convertView=mInflater.inflate(R.layout.sdcard__entry_adapter_activity,null);
holder=new ViewHolder();
holder.text=(TextView)convertView.findViewById(R.id.text);
holder.icon=(ImageView)convertView.findViewById(R.id.icon);
convertView.setTag(holder);
}else{
holder=(ViewHolder)convertView.getTag();
}
try{
File f=new File(paths.get(position).toString());
if(items.get(position).toString().equals("b1"))
{
holder.text.setText("���ظ�Ŀ¼..");
holder.icon.setImageBitmap(mIcon1);
}
else if(items.get(position).toString().equals("b2"))
{
holder.text.setText("������һ��..");
holder.icon.setImageBitmap(mIcon2);
}
else
{
holder.text.setText(f.getName());
if(f.isDirectory())
{
holder.icon.setImageBitmap(mIcon3);
}
else
{
holder.icon.setImageBitmap(mIcon4);
}
}
}catch (Exception e){
e.printStackTrace();
}
return convertView;
}
private class ViewHolder
{
TextView text;
ImageView icon;
}
}
- 这个时候会用到数据库,因为读取完的数据是存到了数据库中了
package com.pressuretran.prodect.sql;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
public class sqliteOpen extends SQLiteOpenHelper
{
/*
* 数据库的版本和数据库的名字
*/
private static String DB_NAME="product_db";
public final static int DB_VERSION=1;
//String string;
public sqliteOpen(Context context)
{
super(context, DB_NAME, null, DB_VERSION);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db)
{
//这个数据表中多了一个三级菜单
String sql="create table lwn(_id integer primary key, series varchar(50) ," +
" type varchar(50) ," +
"data varchar(20) ,"+
"things varchar(50) ,"+
"price varchar(20)"+
")";
db.execSQL(sql);
//下面的表中没有菜单,菜单当表名
String sql_Pressure_p2x="create table pressure_p2x(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_p2x);
String sql_Pressure_p3x="create table pressure_p3x(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_p3x);
String sql_Pressure_p4x="create table pressure_p4x(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_p4x);
String sql_Pressure_pmd235="create table pressure_pmd235(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmd235);
String sql_Pressure_fmd630="create table pressure_fmd630(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_fmd630);
String sql_Pressure_fmd633="create table pressure_fmd633(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_fmd633);
String sql_Pressure_pmc731="create table pressure_pmc731(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc731);
String sql_Pressure_pmp731="create table pressure_pmp731(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmp731);
String sql_Pressure_pmc631="create table pressure_pmc631(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc631);
String sql_Pressure_pmc635="create table pressure_pmc635(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc635);
String sql_Pressure_pmp635="create table pressure_pmp635(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmp635);
String sql_Pressure_pmc41="create table pressure_pmc41(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc41);
String sql_Pressure_pmc45="create table pressure_pmc45(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc45);
String sql_Pressure_pmp41="create table pressure_pmp41(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmp41);
String sql_Pressure_pmp45="create table pressure_pmp45(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmp45);
String sql_Pressure_pmp46="create table pressure_pmp46(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmp46);
String sql_Pressure_pmp48="create table pressure_pmp48(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmp48);
String sql_Pressure_pmc133="create table pressure_pmc133(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc133);
String sql_Pressure_pmc1331="create table pressure_pmc1331(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc1331);
String sql_Pressure_pmc134="create table pressure_pmc134(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc134);
String sql_Pressure_pmc134z="create table pressure_pmc134z(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc134z);
String sql_Pressure_pmc330="create table pressure_pmc330(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc330);
String sql_Pressure_pmc430z="create table pressure_pmc430z(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc430z);
String sql_Pressure_pmc531="create table pressure_pmc531(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc531);
String sql_Pressure_pmc534="create table pressure_pmc534(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc534);
String sql_Pressure_pmc534z="create table pressure_pmc534z(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc534z);
String sql_Pressure_pmc535="create table pressure_pmc535(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc535);
String sql_Pressure_pmc535z="create table pressure_pmc535z(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc535z);
String sql_Pressure_pmc536="create table pressure_pmc536(_id integer primary key, series varchar(50) , type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc536);
String sql_Pressure_pmc536z="create table pressure_pmc536z(_id integer primary key, series varchar(50) ,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_Pressure_pmc536z);
//spinner的那个
String sql_spinner="create table spinner(_id integer primary key,data varchar(50))";
db.execSQL(sql_spinner);
for (int i = 0; i < 100; i++) {
updateSpinner(db,"0",i);
}
//型号的那个
String sql_spinner_str="create table spinner_str(_id integer primary key,data varchar(50))";
db.execSQL(sql_spinner_str);
for (int i = 0; i < 50; i++) {
updateSpinner_str(db,"0",i);
}
String sql_final="create table final(_id integer primary key,type varchar(50) ,data varchar(20),things varchar(50),price varchar(20))";
db.execSQL(sql_final);
for (int i = 0; i < 50; i++) {
updateFinal(db," "," "," "," ",i);
}
}
public void updateSpinner(SQLiteDatabase db,String str1,int i)
{
String sql="insert into spinner (data,_id) values (?,?)";
db.execSQL(sql,new Object[]{str1,i});
}
public void updateSpinner_str(SQLiteDatabase db,String str2,int i)
{
String sql="insert into spinner_str (data,_id) values (?,?)";
db.execSQL(sql,new Object[]{str2,i});
}
public void updateFinal(SQLiteDatabase db,String str1,String str2,String str3,String str4,int i)
{
String sql="insert into final(type,data,things,price,_id) values (?,?,?,?,?)";
db.execSQL(sql,new Object[]{str1,str2,str3,str4,i});
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
db.execSQL("drop table if exits lwn");
System.out.println("更新");
}
}
下面是帮助类:
package com.pressuretran.prodect.sql;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import android.R.integer;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import android.widget.Toast;
public class sqlDbHelper
{
private static final String TAG = null;
private Context mContext;
private SQLiteDatabase db;
public sqlDbHelper(Context mContext)
{
//打开db
db = new sqliteOpen(mContext).getWritableDatabase();
}
public void inspect_delete(String name)
{
String sql="delete from "+name;
db.execSQL(sql);
}
//1:向数据库插入数据
public void inspect_insert(String sqlName,String series, String type,String data,String things,String price )
{
String sql="insert into "+sqlName+" (series,type,data,things,price) values (?,?,?,?,?)";
db.execSQL(sql,new Object[]{series,type,data,things,price});
}
public ArrayList<String> inspect_query(String series)
{
Cursor cursor = null ;
ArrayList result=new ArrayList();
try {
cursor = db.rawQuery("select * from lwn where series="+"'"+series+"'", null);
cursor.moveToFirst();
while(!cursor.isAfterLast()){
String serie=cursor.getString(cursor.getColumnIndex("series"));
String type=cursor.getString(cursor.getColumnIndex("type"));
String data=cursor.getString(cursor.getColumnIndex("data"));
String things=cursor.getString(cursor.getColumnIndex("things"));
String price=cursor.getString(cursor.getColumnIndex("price"));
/* HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("type", type);
hashMap.put("things", things);
hashMap.put("data", data);
hashMap.put("price", price);
result.add(hashMap);*/
result.add(serie);
result.add(type);
result.add(data);
result.add(things);
result.add(price);
cursor.moveToNext();
}
}finally
{
if (cursor != null) {
try {
cursor.close();
} catch (Exception e) {
//ignore this
}
}
}
return result;
}
//1:向数据库插入数据
public void insertNong(String series, String type,String data,String things,String price )
{
String sql="insert into lwn (series,type,data,things,price) values (?,?,?,?,?)";
db.execSQL(sql,new Object[]{series,type,data,things,price});
}
/*
* 2:删除以_id来删除对应的行
*/
public void delete(int id)
{
String sql="delete from lwn where _id=?";
System.out.println("删除了第"+id+"条");
db.execSQL(sql,new Object[]{id});
}
//从lwn表中查询series这个子短下面的所有
public ArrayList<String> rawMyQuerySeries()
{
ArrayList result=new ArrayList();
Cursor cursor = db.rawQuery("select series from lwn ", null);
cursor.moveToFirst();
while(!cursor.isAfterLast())
{
String series=cursor.getString(cursor.getColumnIndex("series"));
HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("", series);
result.add(series);
cursor.moveToNext();
}
return result;
}
public ArrayList<String> rawMyQueryType(String sqlName)
{
ArrayList result=new ArrayList();
Cursor cursor = db.rawQuery("select type from "+sqlName, null);
cursor.moveToFirst();
while(!cursor.isAfterLast())
{
String type=cursor.getString(cursor.getColumnIndex("type"));
HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("", type);
result.add(type);
cursor.moveToNext();
}
return result;
}
public ArrayList<String> rawMyQueryData()
{
ArrayList result=new ArrayList();
Cursor cursor = db.rawQuery("select data from lwn", null);
cursor.moveToFirst();
while(!cursor.isAfterLast())
{
String data=cursor.getString(cursor.getColumnIndex("data"));
HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("", data);
result.add(data);
cursor.moveToNext();
}
return result;
}
public ArrayList<String> rawMyQueryThings()
{
ArrayList result=new ArrayList();
Cursor cursor = db.rawQuery("select things from lwn", null);
cursor.moveToFirst();
while(!cursor.isAfterLast())
{
String things=cursor.getString(cursor.getColumnIndex("things"));
HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("", things);
result.add(things);
cursor.moveToNext();
}
return result;
}
public ArrayList<String> rawMyQueryPrice()
{
ArrayList result=new ArrayList();
Cursor cursor = db.rawQuery("select price from lwn", null);
cursor.moveToFirst();
while(!cursor.isAfterLast())
{
String price=cursor.getString(cursor.getColumnIndex("price"));
HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("", price);
result.add(price);
cursor.moveToNext();
}
return result;
}
/*
* 4也是查寻,但是返回的是Cursor
*/
public Cursor rawQuery()
{
Cursor cursor = db.rawQuery("select * from lwn", null);
return cursor;
}
//-----4:查询所有的数据
public ArrayList rawMyQuery()
{
ArrayList result=new ArrayList();
System.out.println("数据库创建了");
Cursor cursor = db.rawQuery("select * from lwn", null);
cursor.moveToFirst();
while(!cursor.isAfterLast())
{
String series=cursor.getString(cursor.getColumnIndex("series"));
String type=cursor.getString(cursor.getColumnIndex("type"));
String data=cursor.getString(cursor.getColumnIndex("data"));
String things=cursor.getString(cursor.getColumnIndex("things"));
String price=cursor.getString(cursor.getColumnIndex("price"));
HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("series", series);
hashMap.put("type", type);
hashMap.put("data", data);
hashMap.put("things", things);
hashMap.put("price", price);
result.add(hashMap);
cursor.moveToNext();
}
return result;
}
/*
* 4
*/
//-----2:
public void delete(String name,String type)
{
String sql="delete from data where name=? and type=?";
db.execSQL(sql,new Object[]{name,type});
}
public void delete()
{
String sql="delete from lwn";
db.execSQL(sql);
}
public void close()
{
db.close();
}
public ArrayList<String> rawInspectSpinnerSql(String sqlName, String string)
{
Cursor cursor = null ;
ArrayList result=new ArrayList();
try {
cursor = db.rawQuery("select data,things from "+sqlName+" where type="+"'"+string+"'", null);
cursor.moveToFirst();
while(!cursor.isAfterLast()){
String data=cursor.getString(cursor.getColumnIndex("data"));
String things=cursor.getString(cursor.getColumnIndex("things"));
result.add(data+" "+things);
cursor.moveToNext();
}
}finally
{
if (cursor != null) {
try {
cursor.close();
} catch (Exception e) {
//ignore this
}
}
}
return result;
}
/*
* 查询的是最后一个
*/
public String rawInspectEditSql(String sqlName, String string1,String string2,String string3)
{
Cursor cursor = null ;
String s=new String() ;
try {
cursor = db.rawQuery("select price from "+sqlName+" where type="+"'"+string1+"'and"+" data="+"'"+string2+"'"+"and"+" things="+"'"+string3+"'", null);
cursor.moveToFirst();
while(!cursor.isAfterLast()){
s=cursor.getString(cursor.getColumnIndex("price"));
cursor.moveToNext();
}
}finally
{
if (cursor != null) {
try {
cursor.close();
} catch (Exception e) {
//ignore this
}
}
}
return s;
}
//更新数据表,这样就可以了吧!
public void updateSpinner(String str,int i)
{
db.execSQL("update spinner set data="+"'"+str+"'"+"where _id="+i);
}
public ArrayList<String> rawInspectSpinner()
{
Cursor cursor = null ;
ArrayList result=new ArrayList();
try {
cursor = db.rawQuery("select * from spinner ", null);
cursor.moveToFirst();
while(!cursor.isAfterLast()){
String data=cursor.getString(cursor.getColumnIndex("data"));
result.add(data);
cursor.moveToNext();
}
}finally
{
if (cursor != null) {
try {
cursor.close();
} catch (Exception e) {
//ignore this
}
}
}
return result;
}
//更新数据表,这样就可以了吧!
public void updateSpinner_str(String str,int i)
{
db.execSQL("update spinner_str set data="+"'"+str+"'"+"where _id="+i);
}
public ArrayList<String> rawInspectSpinner_str()
{
Cursor cursor = null ;
ArrayList result=new ArrayList();
try {
cursor = db.rawQuery("select * from spinner_str ", null);
cursor.moveToFirst();
while(!cursor.isAfterLast()){
String data=cursor.getString(cursor.getColumnIndex("data"));
result.add(data);
cursor.moveToNext();
}
}finally
{
if (cursor != null) {
try {
cursor.close();
} catch (Exception e) {
//ignore this
}
}
}
return result;
}
public void deleteFinal()
{
String sql="delete from final";
db.execSQL(sql);
}
public void updateFinal(String str1,String str2,String str3,String str4,int i)
{
Log.v("final", "走了"+":"+str1+":"+str2+":"+str3+":"+str4+":"+i);
db.execSQL("update final set type="+"'"+str1+"'"+" , data="+"'"+str2+"'"+" , things="+"'"+str3+"'"+" , price="+"'"+str4+"'"+" where _id="+i);
Log.v("final", "执行了");
}
//1:向数据库插入数据
public void insertFinal( String type,String data,String things,String price )
{
String sql="insert into final (type,data,things,price) values (?,?,?,?)";
db.execSQL(sql,new Object[]{type,data,things,price});
}
public ArrayList<String> rawInspectFinal()
{
Cursor cursor = null ;
ArrayList result=new ArrayList();
try {
cursor = db.rawQuery("select * from final ", null);
cursor.moveToFirst();
while(!cursor.isAfterLast()){
String type=cursor.getString(cursor.getColumnIndex("type"));
String data=cursor.getString(cursor.getColumnIndex("data"));
String things=cursor.getString(cursor.getColumnIndex("things"));
String price=cursor.getString(cursor.getColumnIndex("price"));
result.add(type);
result.add(data);
result.add(data);
result.add(price);
cursor.moveToNext();
}
}finally
{
if (cursor != null) {
try {
cursor.close();
} catch (Exception e) {
//ignore this
}
}
}
Log.v("final", "result="+result);
return result;
}
}
- 读取完事之后会有哥进度条界面,其实这个不完善,需要加到一块去,这个时候的数据表,其实已经是分开了,根据二级菜单的名字,分别对应一张表
package com.pressuretran.prodect.activity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.pressuretran.prodect.R;
import com.pressuretran.prodect.sdcard.sdcard_entryFileManagerActivity;
import com.pressuretran.prodect.sql.sqlDbHelper;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.ProgressBar;
import android.widget.TextView;
public class progressActivity extends Activity {
//这个界面就是分离表的
private ProgressBar progress;
private TextView tv;
private sqlDbHelper dbHlper;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.progress);
progress=(ProgressBar) findViewById(R.id.progress);
tv=(TextView) findViewById(R.id.tv);
dbHlper=new sqlDbHelper(this);
}
//
@Override
protected void onResume() {
DownloadTask dTask = new DownloadTask();
dTask.execute(100);
super.onResume();
}
private void init(String str1,String str2) {
dbHlper.inspect_delete(str1);
ArrayList<String> inspect = dbHlper.inspect_query(str2);
//此处有bug必须的表中都有数据,数据能被5整除,有个null就不对了
for (int i = 0; i < inspect.size(); ) {
dbHlper.inspect_insert(str1, inspect.get(i), inspect.get(i+1), inspect.get(i+2), inspect.get(i+3), inspect.get(i+4));
Log.v("sb", inspect.get(i).toString()+":"+ inspect.get(i+1).toString()+":"+inspect.get(i+2).toString()+":"+inspect.get(i+3).toString()+":"+inspect.get(i+4).toString());
i=i+5;
}
}
class DownloadTask extends AsyncTask<Integer, Integer, String>{
//后面尖括号内分别是参数(例子里是线程休息时间),进度(publishProgress用到),返回值 类型
@Override
protected void onPreExecute() {
//第一个执行方法
super.onPreExecute();
}
@Override
protected String doInBackground(Integer... params) {
//第二个执行方法,onPreExecute()执行完后执行
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//按照条件查询,将数据分别插入数据库
init("pressure_p2x","P2X系列");
init("pressure_p3x","P3X系列");
init("pressure_p4x","P4X系列");
init("pressure_pmd235","PMD235型");
init("pressure_fmd630","FMD630型");
init("pressure_fmd633","FMD633型");
init("pressure_pmc731","PMC731型");
init("pressure_pmp731","PMP731型");
init("pressure_pmc631","PMC631型");
init("pressure_pmc635","PMC635型");
init("pressure_pmp635","PMP635型");
init("pressure_pmc41","PMC41型");
init("pressure_pmc45","PMC45型");
init("pressure_pmp41","PMP41型");
init("pressure_pmp45","PMP45型");
init("pressure_pmp46","PMP46型");
init("pressure_pmp48","PMP48型");
init("pressure_pmc133","PMC133型");
init("pressure_pmc1331","PMC133IZ型");
init("pressure_pmc134","PMC134型");
init("pressure_pmc134z","PMC134Z型");
init("pressure_pmc330","PMC330型");
init("pressure_pmc430z","PMC430Z型");
init("pressure_pmc531","PMC531型");
init("pressure_pmc534","PMC534型");
init("pressure_pmc534z","PMC534Z型");
init("pressure_pmc535","PMC535型");
init("pressure_pmc535z","PMC535Z型");
init("pressure_pmc536","PMC536型");
init("pressure_pmc536z","PMC536Z型");
for(int i=0;i<=100;i++){
progress.setProgress(i);
publishProgress(i);
}
return "执行完毕";
}
@Override
protected void onProgressUpdate(Integer... progress) {
//这个函数在doInBackground调用publishProgress时触发,虽然调用时只有一个参数
//但是这里取到的是一个数组,所以要用progesss[0]来取值
//第n个参数就用progress[n]来取值
tv.setText(progress[0]+"%");
if(tv.getText().toString().equals("100%"))
{
startActivity(new Intent(progressActivity.this,firstMenuActivity.class));
progressActivity.this.finish();
}
super.onProgressUpdate(progress);
}
@Override
protected void onPostExecute(String result) {
//doInBackground返回时触发,换句话说,就是doInBackground执行完后触发
//这里的result就是上面doInBackground执行后的返回值,所以这里是"执行完毕"
setTitle(result);
super.onPostExecute(result);
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//当进度够了才返回
if(keyCode == KeyEvent.KEYCODE_BACK) {
startActivity(new Intent(this,firstMenuActivity.class));
progressActivity.this.finish();
}
return false;
}
}
- 进入二级菜单目录:压力为例
package com.pressuretran.prodect.activity;
import com.pressuretran.prodect.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
/*
* 二级菜单压力界面
*/
public class twoMenuPressureActivity extends Activity {
private Button button_two_one_01;
private Button button_two_one_02;
private Button button_two_one_03;
private Button button_two_two_01;
private Button button_two_two_02;
private Button button_two_two_03;
private Button button_two_three_01;
private Button button_two_three_02;
private Button button_two_three_03;
private Button button_two_three_04;
private Button button_two_three_05;
private Button button_two_four_01;
private Button button_two_four_02;
private Button button_two_four_03;
private Button button_two_four_04;
private Button button_two_four_05;
private Button button_two_four_06;
private Button button_two_five_01;
private Button button_two_five_02;
private Button button_two_five_03;
private Button button_two_five_04;
private Button button_two_five_05;
private Button button_two_five_06;
private Button button_two_five_07;
private Button button_two_five_08;
private Button button_two_five_09;
private Button button_two_five_10;
private Button button_two_five_11;
private Button button_two_five_12;
private Button button_two_five_13;
private Button button_two_sex_01;
private Button button_two_sex_02;
private String button_two_one_string_01;
private String button_two_one_string_02;
private String button_two_one_string_03;
private String button_two_two_string_01;
private String button_two_two_string_02;
private String button_two_two_string_03;
private String button_two_three_string_01;
private String button_two_three_string_02;
private String button_two_three_string_03;
private String button_two_three_string_04;
private String button_two_three_string_05;
private String button_two_four_string_01;
private String button_two_four_string_02;
private String button_two_four_string_03;
private String button_two_four_string_04;
private String button_two_four_string_05;
private String button_two_four_string_06;
private String button_two_five_string_01;
private String button_two_five_string_02;
private String button_two_five_string_03;
private String button_two_five_string_04;
private String button_two_five_string_05;
private String button_two_five_string_06;
private String button_two_five_string_07;
private String button_two_five_string_08;
private String button_two_five_string_09;
private String button_two_five_string_10;
private String button_two_five_string_11;
private String button_two_five_string_12;
private String button_two_five_string_13;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.two_menu_pressure_activity);//two_menu_pressure_activity.xml
init();
}
private void init()
{
button_two_one_01=(Button) findViewById(R.id.button_two_one_01);button_two_one_string_01=button_two_one_01.getText().toString().trim();button_two_one_01.setOnClickListener(new listener());
button_two_one_02=(Button) findViewById(R.id.button_two_one_02);button_two_one_string_02=button_two_one_02.getText().toString().trim();button_two_one_02.setOnClickListener(new listener());
button_two_one_03=(Button) findViewById(R.id.button_two_one_03);button_two_one_string_03=button_two_one_03.getText().toString().trim();button_two_one_03.setOnClickListener(new listener());
button_two_two_01=(Button) findViewById(R.id.button_two_two_01);button_two_two_string_01=button_two_two_01.getText().toString().trim();button_two_two_01.setOnClickListener(new listener());
button_two_two_02=(Button) findViewById(R.id.button_two_two_02);button_two_two_string_02=button_two_two_02.getText().toString().trim();button_two_two_02.setOnClickListener(new listener());
button_two_two_03=(Button) findViewById(R.id.button_two_two_03);button_two_two_string_03=button_two_two_03.getText().toString().trim();button_two_two_03.setOnClickListener(new listener());
button_two_three_01=(Button) findViewById(R.id.button_two_three_01);button_two_three_string_01=button_two_three_01.getText().toString().trim();button_two_three_01.setOnClickListener(new listener());
button_two_three_02=(Button) findViewById(R.id.button_two_three_02);button_two_three_string_02=button_two_three_02.getText().toString().trim();button_two_three_02.setOnClickListener(new listener());
button_two_three_03=(Button) findViewById(R.id.button_two_three_03);button_two_three_string_03=button_two_three_03.getText().toString().trim();button_two_three_03.setOnClickListener(new listener());
button_two_three_04=(Button) findViewById(R.id.button_two_three_04);button_two_three_string_04=button_two_three_04.getText().toString().trim();button_two_three_04.setOnClickListener(new listener());
button_two_three_05=(Button) findViewById(R.id.button_two_three_05);button_two_three_string_05=button_two_three_05.getText().toString().trim();button_two_three_05.setOnClickListener(new listener());
button_two_four_01=(Button) findViewById(R.id.button_two_four_01);button_two_four_string_01=button_two_four_01.getText().toString().trim();button_two_four_01.setOnClickListener(new listener());
button_two_four_02=(Button) findViewById(R.id.button_two_four_02);button_two_four_string_02=button_two_four_02.getText().toString().trim();button_two_four_02.setOnClickListener(new listener());
button_two_four_03=(Button) findViewById(R.id.button_two_four_03);button_two_four_string_03=button_two_four_03.getText().toString().trim();button_two_four_03.setOnClickListener(new listener());
button_two_four_04=(Button) findViewById(R.id.button_two_four_04);button_two_four_string_04=button_two_four_04.getText().toString().trim();button_two_four_04.setOnClickListener(new listener());
button_two_four_05=(Button) findViewById(R.id.button_two_four_05);button_two_four_string_05=button_two_four_05.getText().toString().trim();button_two_four_05.setOnClickListener(new listener());
button_two_four_06=(Button) findViewById(R.id.button_two_four_06);button_two_four_string_06=button_two_four_06.getText().toString().trim();button_two_four_06.setOnClickListener(new listener());
button_two_five_01=(Button) findViewById(R.id.button_two_five_01);button_two_five_string_01=button_two_five_01.getText().toString().trim();button_two_five_01.setOnClickListener(new listener());
button_two_five_02=(Button) findViewById(R.id.button_two_five_02);button_two_five_string_02=button_two_five_02.getText().toString().trim();button_two_five_02.setOnClickListener(new listener());
button_two_five_03=(Button) findViewById(R.id.button_two_five_03);button_two_five_string_03=button_two_five_03.getText().toString().trim();button_two_five_03.setOnClickListener(new listener());
button_two_five_04=(Button) findViewById(R.id.button_two_five_04);button_two_five_string_04=button_two_five_04.getText().toString().trim();button_two_five_04.setOnClickListener(new listener());
button_two_five_05=(Button) findViewById(R.id.button_two_five_05);button_two_five_string_05=button_two_five_05.getText().toString().trim();button_two_five_05.setOnClickListener(new listener());
button_two_five_06=(Button) findViewById(R.id.button_two_five_06);button_two_five_string_06=button_two_five_06.getText().toString().trim();button_two_five_06.setOnClickListener(new listener());
button_two_five_07=(Button) findViewById(R.id.button_two_five_07);button_two_five_string_07=button_two_five_07.getText().toString().trim();button_two_five_07.setOnClickListener(new listener());
button_two_five_08=(Button) findViewById(R.id.button_two_five_08);button_two_five_string_08=button_two_five_08.getText().toString().trim();button_two_five_08.setOnClickListener(new listener());
button_two_five_09=(Button) findViewById(R.id.button_two_five_09);button_two_five_string_09=button_two_five_09.getText().toString().trim();button_two_five_09.setOnClickListener(new listener());
button_two_five_10=(Button) findViewById(R.id.button_two_five_10);button_two_five_string_10=button_two_five_10.getText().toString().trim();button_two_five_10.setOnClickListener(new listener());
button_two_five_11=(Button) findViewById(R.id.button_two_five_11);button_two_five_string_11=button_two_five_11.getText().toString().trim();button_two_five_11.setOnClickListener(new listener());
button_two_five_12=(Button) findViewById(R.id.button_two_five_12);button_two_five_string_12=button_two_five_12.getText().toString().trim();button_two_five_12.setOnClickListener(new listener());
button_two_five_13=(Button) findViewById(R.id.button_two_five_13);button_two_five_string_13=button_two_five_13.getText().toString().trim();button_two_five_13.setOnClickListener(new listener());
button_two_sex_01=(Button) findViewById(R.id.button_two_sex_01);
button_two_sex_02=(Button) findViewById(R.id.button_two_sex_02);
}
private class listener implements OnClickListener
{
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.button_two_one_01:
//p2x系列
Intent i11=new Intent(twoMenuPressureActivity.this,threeMenuInspectActivity.class);
i11.putExtra("sqlName",button_two_one_string_01);
startActivity(i11);
finish();
break;
case R.id.button_two_one_02:
//p3x系列
Intent i12=new Intent(twoMenuPressureActivity.this,threeMenuInspectActivity.class);
i12.putExtra("sqlName",button_two_one_string_02);
startActivity(i12);
finish();
break;
case R.id.button_two_one_03:
//p4x系列
Intent i13=new Intent(twoMenuPressureActivity.this,threeMenuInspectActivity.class);
i13.putExtra("sqlName",button_two_one_string_03);
startActivity(i13);
finish();
break;
case R.id.button_two_two_01:
//pmd235系列
Intent i21=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i21.putExtra("sqlName",button_two_two_string_01);
startActivity(i21);
finish();
break;
case R.id.button_two_two_02:
//fmd630系列
Intent i22=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i22.putExtra("sqlName",button_two_two_string_02);
startActivity(i22);
finish();
break;
case R.id.button_two_two_03:
//fmd633系列
Intent i23=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i23.putExtra("sqlName",button_two_two_string_03);
startActivity(i23);
finish();
break;
case R.id.button_two_three_01:
//pmc731系列
Intent i31=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i31.putExtra("sqlName",button_two_three_string_01);
startActivity(i31);
finish();
break;
case R.id.button_two_three_02:
//pmp731系列
Intent i32=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i32.putExtra("sqlName",button_two_three_string_02);
startActivity(i32);
finish();
break;
case R.id.button_two_three_03:
//pmc631系列
Intent i33=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i33.putExtra("sqlName",button_two_three_string_03);
startActivity(i33);
finish();
break;
case R.id.button_two_three_04:
//pmc635系列
Intent i34=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i34.putExtra("sqlName",button_two_three_string_04);
startActivity(i34);
finish();
break;
case R.id.button_two_three_05:
//pmp635系列
Intent i35=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i35.putExtra("sqlName",button_two_three_string_05);
startActivity(i35);
finish();
break;
case R.id.button_two_four_01:
//pmc41系列
Intent i41=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i41.putExtra("sqlName",button_two_four_string_01);
startActivity(i41);
finish();
break;
case R.id.button_two_four_02:
//pmc45系列
Intent i42=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i42.putExtra("sqlName",button_two_four_string_02);
startActivity(i42);
finish();
break;
case R.id.button_two_four_03:
//pmp41系列
Intent i43=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i43.putExtra("sqlName",button_two_four_string_03);
startActivity(i43);
finish();
break;
case R.id.button_two_four_04:
//pmp45系列
Intent i44=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i44.putExtra("sqlName",button_two_four_string_04);
startActivity(i44);
finish();
break;
case R.id.button_two_four_05:
//pmp46系列
Intent i45=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i45.putExtra("sqlName",button_two_four_string_05);
startActivity(i45);
finish();
break;
case R.id.button_two_four_06:
//pmp48系列
Intent i46=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i46.putExtra("sqlName",button_two_four_string_06);
startActivity(i46);
finish();
break;
case R.id.button_two_five_01:
//pmc133系列
Intent i51=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i51.putExtra("sqlName",button_two_five_string_01);
startActivity(i51);
finish();
break;
case R.id.button_two_five_02:
//pmc1331系列
Intent i52=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i52.putExtra("sqlName",button_two_five_string_02);
startActivity(i52);
finish();
break;
case R.id.button_two_five_03:
//pmc134系列
Intent i53=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i53.putExtra("sqlName",button_two_five_string_03);
startActivity(i53);
finish();
break;
case R.id.button_two_five_04:
//pmc134z系列
Intent i54=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i54.putExtra("sqlName",button_two_five_string_04);
startActivity(i54);
finish();
break;
case R.id.button_two_five_05:
//pmc330系列
Intent i55=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i55.putExtra("sqlName",button_two_five_string_05);
startActivity(i55);
finish();
break;
case R.id.button_two_five_06:
//pmc430z系列
Intent i56=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i56.putExtra("sqlName",button_two_five_string_06);
startActivity(i56);
finish();
break;
case R.id.button_two_five_07:
//pmc531系列
Intent i57=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i57.putExtra("sqlName",button_two_five_string_07);
startActivity(i57);
finish();
break;
case R.id.button_two_five_08:
//pmc534系列
Intent i58=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i58.putExtra("sqlName",button_two_five_string_08);
startActivity(i58);
finish();
break;
case R.id.button_two_five_09:
//pmc534z系列
Intent i59=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i59.putExtra("sqlName",button_two_five_string_09);
startActivity(i59);
finish();
break;
case R.id.button_two_five_10:
//pmc535系列
Intent i510=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i510.putExtra("sqlName",button_two_five_string_10);
startActivity(i510);
finish();
break;
case R.id.button_two_five_11:
//pmc535z系列
Intent i511=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i511.putExtra("sqlName",button_two_five_string_11);
startActivity(i511);
finish();
break;
case R.id.button_two_five_12:
//pmc536系列
Intent i512=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i512.putExtra("sqlName",button_two_five_string_12);
startActivity(i512);
finish();
break;
case R.id.button_two_five_13:
//pmc536z系列
Intent i513=new Intent(twoMenuPressureActivity.this,threeMenuInspectTwoActivity.class);
i513.putExtra("sqlName",button_two_five_string_13);
startActivity(i513);
finish();
break;
case R.id.button_two_sex_01:
//产品附件
break;
case R.id.button_two_sex_02:
//标准量程
break;
default:
break;
}
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK) {
startActivity(new Intent(this,firstMenuActivity.class));
twoMenuPressureActivity.this.finish();
}
return false;
}
}
- 此时点击的时候,会将按钮的名字传进去到三级界面,会根据她的名字去查询对应的表,然后动态布局,注意三级界面是动态布局得到
package com.pressuretran.prodect.activity;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.BreakIterator;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.zip.Inflater;
import com.pressuretran.prodect.R;
import com.pressuretran.prodect.R.layout;
import com.pressuretran.prodect.csv.dbToDataCsv;
import com.pressuretran.prodect.dataDict.Dict_data;
import com.pressuretran.prodect.dataDict.Dict_type;
import com.pressuretran.prodect.sql.sqlDbHelper;
import com.pressuretran.prodect.sql.sqliteOpen;
import android.R.integer;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Service;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Environment;
import android.os.Vibrator;
import android.provider.MediaStore;
import android.renderscript.Sampler.Value;
import android.support.v4.widget.SimpleCursorAdapter;
import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewParent;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
public class threeMenuInspectTwoActivity extends Activity {
private TextView three_menu_inspect_TextView1;
private TextView three_menu_inspect_TextView2;
private sqlDbHelper dbhelper;
private ArrayList<String> list_type;//从数据库查询出来的所有type值
private List<String> list_data;
private String[] dicts_type;//从数据库查询出来的type转化为数组
private List<EditText> e;
private ListView three_menu_inspect_listView;
List<String> datalist;//这个是spniner填充适配器的集合
String rawInspectEditSql;//数据库查询出来的对应的price的值
private TextView editText;//这个是price的控件,原里是找到父控件,然后再findprice控件,设置值
private String three_menu_layout_inspect_spinner_textView1;
private String three_menu_layout_inspect_spinner_textView2;
private TextView three_menu_inspect_editText1;
private TextView three_menu_inspect_editText2;
ArrayList<String> arrayList = new ArrayList<String>();
private HashMap<Integer, String> hashMap;//这个地方就是就是放价格的hashMap
private StringBuffer sb=new StringBuffer();
private String ss;
private String sqlName="lwn";
private String a;
String string;
boolean T=true;
private String strName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.three_menu_inspect_two);
three_menu_inspect_TextView1=(TextView) findViewById(R.id.three_menu_inspect_TextView1);
three_menu_inspect_TextView2=(TextView) findViewById(R.id.three_menu_inspect_TextView2);
three_menu_inspect_editText1=(TextView) findViewById(R.id.three_menu_inspect_editText1);
three_menu_inspect_editText2=(TextView) findViewById(R.id.three_menu_inspect_editText2);
Button three_menu_inspect_button1=(Button)findViewById(R.id.three_menu_inspect_button1);
three_menu_inspect_button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
AlertDialog.Builder builder = new AlertDialog.Builder(
threeMenuInspectTwoActivity.this);
builder.setTitle("导出");
builder.setNegativeButton("确定",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dbhelper.updateFinal("系列:", three_menu_inspect_TextView1.getText().toString(), "基价:", three_menu_inspect_TextView2.getText().toString(),0);
dbhelper.updateFinal("产品型号:", three_menu_inspect_editText1.getText().toString(), "产品价格:", three_menu_inspect_editText2.getText().toString(),dicts_type.length+1);
for (int i = dicts_type.length+2; i < 50; i++) {
dbhelper.updateFinal(" ", " ", " ", " ",i);
}
File file = new File("/sdcard/data");
file.mkdir();
Cursor cursor =new sqliteOpen(threeMenuInspectTwoActivity.this).getWritableDatabase().rawQuery("select * from final" , null);
new dbToDataCsv(threeMenuInspectTwoActivity.this,
cursor, strName + ".csv")
.ExportToDataCSV(file.getPath());
}
});
builder.setPositiveButton("取消",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
}
});
builder.create().show();
}
});
init();
dbhelper=new sqlDbHelper(this);
three_menu_inspect_listView=(ListView) findViewById(R.id.three_menu_inspect_listView);
three_menu_inspect_listView.setAdapter(new myAdapter(this));
//
//Log.v("lwn", ":"+arrayList.toString());
}
@Override
protected void onResume() {
Log.v("zy", "lwn+OnResume");
super.onResume();
}
private void init() {
if (T) {
Intent intent = threeMenuInspectTwoActivity.this.getIntent();
sqlName = intent.getStringExtra("sqlName");
Log.v("sqlName", sqlName);
if(sqlName.equals("PMD235型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMD235选型及报价");
three_menu_inspect_TextView2.setText("7800");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmd235";
}else if(sqlName.equals("FMD630型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("FMD630选型及报价");
three_menu_inspect_TextView2.setText("9600");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_fmd630";
}else if(sqlName.equals("FMD633型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("FMD633选型及报价");
three_menu_inspect_TextView2.setText("17000");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_fmd633";
}
else if(sqlName.equals("PMC731型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC731选型及报价");
three_menu_inspect_TextView2.setText("6600");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc731";
}else if(sqlName.equals("PMP731型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMP731选型及报价");
three_menu_inspect_TextView2.setText("6900");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmp731";
}
else if(sqlName.equals("PMC631型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC631选型及报价");
three_menu_inspect_TextView2.setText("8700");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc631";
}else if(sqlName.equals("PMC635型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC635选型及报价");
three_menu_inspect_TextView2.setText("8700");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc635";
}else if(sqlName.equals("PMP635型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMP635选型及报价");
three_menu_inspect_TextView2.setText("8900");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmp635";
}
else if(sqlName.equals("PMC41型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC41选型及报价");
three_menu_inspect_TextView2.setText("4810");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc41";
}else if(sqlName.equals("PMC45型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC45选型及报价");
three_menu_inspect_TextView2.setText("6960");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc45";
}else if(sqlName.equals("PMP41型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMP41选型及报价");
three_menu_inspect_TextView2.setText("4810");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmp41";
}
else if(sqlName.equals("PMP45型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMP45选型及报价");
three_menu_inspect_TextView2.setText("6720");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmp45";
}else if(sqlName.equals("PMP46型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMP46选型及报价");
three_menu_inspect_TextView2.setText("7400");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmp46";
}else if(sqlName.equals("PMP48型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMP48选型及报价");
three_menu_inspect_TextView2.setText("7840");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmp48";
}
else if(sqlName.equals("PMC133型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC133选型及报价");
three_menu_inspect_TextView2.setText("3700");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc133";
}else if(sqlName.equals("PMC133IZ型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC133IZ选型及报价");
three_menu_inspect_TextView2.setText("4200");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc1331";
}else if(sqlName.equals("PMC134型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC134选型及报价");
three_menu_inspect_TextView2.setText("4500");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc134";
}else if(sqlName.equals("PMC134Z型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC134Z选型及报价");
three_menu_inspect_TextView2.setText("5600");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc134z";
}else if(sqlName.equals("PMC330型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC330选型及报价");
three_menu_inspect_TextView2.setText("4200");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc330";
}else if(sqlName.equals("PMC430Z型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC430Z选型及报价");
three_menu_inspect_TextView2.setText("4700");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc430z";
}else if(sqlName.equals("PMC531型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC531选型及报价");
three_menu_inspect_TextView2.setText("5700");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc531";
}else if(sqlName.equals("PMC534型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC534选型及报价");
three_menu_inspect_TextView2.setText("5700");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc534";
}else if(sqlName.equals("PMC534Z型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC534Z选型及报价");
three_menu_inspect_TextView2.setText("6200");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc534z";
}else if(sqlName.equals("PMC535型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC535选型及报价");
three_menu_inspect_TextView2.setText("5700");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc535";
}else if(sqlName.equals("PMC535Z型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC535Z选型及报价");
three_menu_inspect_TextView2.setText("6200");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc535z";
}else if(sqlName.equals("PMC536型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC536选型及报价");
three_menu_inspect_TextView2.setText("5700");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc536";
}else if(sqlName.equals("PMC536Z型"))
{
strName=sqlName;
three_menu_inspect_TextView1.setText("PMC536Z选型及报价");
three_menu_inspect_TextView2.setText("6200");
ss= sqlName.subSequence(0, sqlName.length()-1)+"";
sqlName="pressure_pmc536z";
}
}
}
public class myAdapter extends BaseAdapter
{
private Context mconContext;
public myAdapter(Context context) {
this.mconContext=context;
List<Dict_type> dictItem = new DictDaoImpl(context).getDictItem("");
}
@Override
public int getCount() {
return dicts_type.length;
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int possition1, View view, ViewGroup parent) {
viewHolder holder;
Log.v("zy", "lwn+getView");
if(view==null)
{
LayoutInflater lf = (LayoutInflater) threeMenuInspectTwoActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view= lf.inflate(R.layout.three_menu_layout_inspect, null);
holder=new viewHolder();
holder.three_menu_layout_inspect_textView=(TextView)view.findViewById(R.id.three_menu_layout_inspect_textView);
holder.three_menu_layout_inspect_spinner=(Spinner)view.findViewById(R.id.three_menu_layout_inspect_spinner);
holder.three_menu_layout_inspect_editText=(TextView) view.findViewById(R.id.three_menu_layout_inspect_editText);
view.setTag(holder);
}else{
holder=(viewHolder) view.getTag();
}
holder.three_menu_layout_inspect_textView.setText( dicts_type[possition1]);
spinner(possition1, holder);
holder.three_menu_layout_inspect_editText.setText(three_menu_layout_inspect_spinner_textView1);
return view;
}
public void product()
{
}
boolean BIAOZHI=true;
private void spinner(final int possition, viewHolder holder) {
datalist=new ArrayList<String>();//此处的数据就是从数据库查出来
List<Dict_data> list_data_a = new ArrayList<Dict_data>();
list_data_a=new DictDaoData(threeMenuInspectTwoActivity.this).getDictItem(dicts_type[possition]);
datalist.add(0," ");
for (Dict_data retList : list_data_a) {
datalist.add(retList.getData());
}
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(threeMenuInspectTwoActivity.this, android.R.layout.simple_spinner_item,datalist);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
holder.three_menu_layout_inspect_spinner.setAdapter( arrayAdapter);
holder.three_menu_layout_inspect_spinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
//单击选中的这个然后将内容设置给后面的editText,根据三个字段的值来判断第四个字段的值,字段直接在view下面能娶到
String item =(String)arrayAdapter.getItem(position);//获取每个条目
ViewParent parent2 = parent.getParent();//获取父类控件
TextView tt = (TextView) ((LinearLayout) parent2).findViewById(R.id.three_menu_layout_inspect_textView);//将它转型
String str1 = tt.getText().toString().trim();//取出空格
if (item.equals(" ")) {
three_menu_layout_inspect_spinner_textView1=" ";
a=" ";
}else {
three_menu_layout_inspect_spinner_textView1=item.split(" ")[0].toString().trim();//分割字符串
a=item.substring(three_menu_layout_inspect_spinner_textView1.length(), item.length());//分割
}
//a = a.trim();
while(a.startsWith(" ")){
a = a.substring(1,a.length()).trim();
}
while(a.endsWith(" ")){
a = a.substring(0,a.length()-1).trim();
}
Log.v("ai", three_menu_layout_inspect_spinner_textView1);
dbhelper.updateSpinner_str(three_menu_layout_inspect_spinner_textView1,possition);
ArrayList<String> array_price_str = dbhelper.rawInspectSpinner_str();
String sum_str=ss;
String [] a2=new String[dicts_type.length];
for(int i = 0;i < dicts_type.length; i ++){
if (i==0) {
sum_str=sum_str+"-";
}
a2[i]=array_price_str.get(i);
sum_str=sum_str+""+a2[i];
}
three_menu_inspect_editText1.setText(sum_str+"");
editText= (TextView) ((LinearLayout) parent2).findViewById(R.id.three_menu_layout_inspect_editText);
String item2= editText.getText().toString();
rawInspectEditSql = dbhelper.rawInspectEditSql(sqlName,str1,three_menu_layout_inspect_spinner_textView1,a);//根据条件查询出来的
if (rawInspectEditSql.equals("另议")) {
editText.setText("另议");
dbhelper.updateSpinner("另议",possition);
}else{
int lwn = Integer.parseInt(rawInspectEditSql+"0");
//Log.v("cao", "rawInspectEditSql="+rawInspectEditSql+"lwn");
editText.setText(lwn/10+"");
dbhelper.updateSpinner(lwn/10+"",possition);
}
ArrayList<String> array_price = dbhelper.rawInspectSpinner();
dbhelper.updateFinal(str1, three_menu_layout_inspect_spinner_textView1, a, editText.getText().toString(),possition+1);
//方法4
int sum = 0 ;
int[] a1=new int[dicts_type.length];
for(int i = 0;i < dicts_type.length; i ++){
//先遍历每个值,看看有没有"另议",有了就跳出不循环,
if (array_price.get(i).equals("另议")) {
a1[i]= -1000000;
Log.v("cao", "else"+sum);
}
else {
a1[i]=Integer.parseInt(array_price.get(i));
}
sum=sum+a1[i];
}
Log.v("sum", "sum="+sum);
if (sum<0) {
three_menu_inspect_editText2.setText("另议");
}else{
three_menu_inspect_editText2.setText(sum+Integer.parseInt(three_menu_inspect_TextView2.getText().toString())+"");
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
//不按 的话不做任何处理
}
});
}
}
public class viewHolder
{
TextView three_menu_layout_inspect_textView;
Spinner three_menu_layout_inspect_spinner;
TextView three_menu_layout_inspect_editText;
}
public class DictDaoData{
private Context context;
public DictDaoData(Context context) {
this.context = context;
}
public List<Dict_data> getDictItem(String str) {
//只把type这个类型这删除重复元素
list_data = dbhelper.rawInspectSpinnerSql(sqlName,str);//查询数据库的type
Object[] dictss_data = list_data.toArray(new Object[list_data
.size()]);
//转为数组
String[] dicts_data = new String[dictss_data.length];
for (int i = 0; i < dictss_data.length; i++) {
dicts_data[i] = (String) dictss_data[i];
}
List<Dict_data> retList = new ArrayList<Dict_data>();
for (int j = 0; j < dicts_data.length; j++) {
Dict_data dict = new Dict_data();
dict.setData(dicts_data[j]);
retList.add(dict);
}
return retList;
}
}
//这个类中的方法能返回数量,我只要type去重复之后的
public class DictDaoImpl {
private Context context;
public DictDaoImpl(Context context) {
this.context = context;
}
/*
* 如果这个对象不存在
*/
public boolean isExist() {
return false;
}
//这个类的这个方法,是返回一个list集合
public List<Dict_type> getDictItem(String dictId) {
//只把type这个类型这删除重复元素
list_type = dbhelper.rawMyQueryType(sqlName);//查询数据库的type
for (int i = 0; i < list_type.size() - 1; i++) {
for (int j = list_type.size() - 1; j > i; j--) {
if(list_type.get(j).toString().equals(list_type.get(i).toString())){
list_type.remove(j);
}
}
} //去重
Object[] dictss_type = list_type.toArray(new Object[list_type
.size()]);
//转为数组
dicts_type= new String[dictss_type.length];
for (int i = 0; i < dictss_type.length; i++) {
dicts_type[i] = (String) dictss_type[i];
}
List<Dict_type> retList = new ArrayList<Dict_type>();
for (int j = 0; j < dicts_type.length; j++) {
Dict_type dict = new Dict_type();
dict.setType(dicts_type[j]);
retList.add(dict);
}
return retList;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
threeMenuInspectTwoActivity.this.finish();
Intent intent=new Intent(threeMenuInspectTwoActivity.this,twoMenuPressureActivity.class);
startActivity(intent);
}
return true;
}
}
- 上述,选择完成之后单机导出,就可以了,会在data目录生成我们需要的保存之后的表格,上面是2种系列的类型,所以分了2种,第二种就不写了
package com.pressuretran.prodect.activity;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.BreakIterator;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.zip.Inflater;
import com.pressuretran.prodect.R;
import com.pressuretran.prodect.R.layout;
import com.pressuretran.prodect.csv.dbToDataCsv;
import com.pressuretran.prodect.dataDict.Dict_data;
import com.pressuretran.prodect.dataDict.Dict_type;
import com.pressuretran.prodect.sdcard.sdcard_entryFileManagerActivity;
import com.pressuretran.prodect.sql.sqlDbHelper;
import com.pressuretran.prodect.sql.sqliteOpen;
import android.R.integer;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Service;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Environment;
import android.os.Vibrator;
import android.provider.MediaStore;
import android.renderscript.Sampler.Value;
import android.support.v4.widget.SimpleCursorAdapter;
import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewParent;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
public class threeMenuInspectActivity extends Activity {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private TextView three_menu_inspect_TextView1;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private sqlDbHelper dbhelper;
<span style="white-space:pre"> </span>private ArrayList<String> list_type;//从数据库查询出来的所有type值
<span style="white-space:pre"> </span>private List<String> list_data;
<span style="white-space:pre"> </span>private String[] dicts_type;//从数据库查询出来的type转化为数组
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private List<EditText> e;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private ListView three_menu_inspect_listView;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private List<String> datalist;//这个是spniner填充适配器的集合
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private String rawInspectEditSql;//数据库查询出来的对应的price的值
<span style="white-space:pre"> </span>private TextView editText;//这个是price的控件,原里是找到父控件,然后再findprice控件,设置值
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private String three_menu_layout_inspect_spinner_textView1;
<span style="white-space:pre"> </span>private String three_menu_layout_inspect_spinner_textView2;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private TextView three_menu_inspect_editText1;
<span style="white-space:pre"> </span>private TextView three_menu_inspect_editText2;
<span style="white-space:pre"> </span>private ArrayList<String> arrayList = new ArrayList<String>();
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private HashMap<Integer, String> hashMap;//这个地方就是就是放价格的hashMap
<span style="white-space:pre"> </span>private StringBuffer sb=new StringBuffer();
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private String sqlName="lwn";
<span style="white-space:pre"> </span>private String a;
<span style="white-space:pre"> </span>private String string;
<span style="white-space:pre"> </span>boolean T=true;
<span style="white-space:pre"> </span>private ArrayList<String> rawInspectFinal;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private String strName;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>protected void onCreate(Bundle savedInstanceState) {
<span style="white-space:pre"> </span>super.onCreate(savedInstanceState);
<span style="white-space:pre"> </span>setContentView(R.layout.three_menu_inspect);
<span style="white-space:pre"> </span>three_menu_inspect_TextView1=(TextView) findViewById(R.id.three_menu_inspect_TextView1);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>three_menu_inspect_editText1=(TextView) findViewById(R.id.three_menu_inspect_editText1);
<span style="white-space:pre"> </span>three_menu_inspect_editText2=(TextView) findViewById(R.id.three_menu_inspect_editText2);
<span style="white-space:pre"> </span>init();
<span style="white-space:pre"> </span>Button three_menu_inspect_button1=(Button)findViewById(R.id.three_menu_inspect_button1);
<span style="white-space:pre"> </span>three_menu_inspect_button1.setOnClickListener(new OnClickListener() {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public void onClick(View arg0) {
<span style="white-space:pre"> </span>// TODO Auto-generated method stub
<span style="white-space:pre"> </span>rawInspectFinal = dbhelper.rawInspectFinal();//
<span style="white-space:pre"> </span>AlertDialog.Builder builder = new AlertDialog.Builder(
<span style="white-space:pre"> </span>threeMenuInspectActivity.this);
<span style="white-space:pre"> </span>builder.setTitle("导出");
<span style="white-space:pre"> </span>builder.setNegativeButton("确定",
<span style="white-space:pre"> </span>new DialogInterface.OnClickListener() {
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public void onClick(DialogInterface dialog,
<span style="white-space:pre"> </span>int which) {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>dbhelper.updateFinal("系列:", three_menu_inspect_TextView1.getText().toString(), " ", " ",0);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>dbhelper.updateFinal("产品型号:", three_menu_inspect_editText1.getText().toString(), "产品价格:", three_menu_inspect_editText2.getText().toString(),dicts_type.length+1);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>for (int i = dicts_type.length+2; i < 50; i++) {
<span style="white-space:pre"> </span>dbhelper.updateFinal(" ", " ", " ", " ",i);
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>File file = new File("/sdcard/data");
<span style="white-space:pre"> </span>file.mkdir();
<span style="white-space:pre"> </span>Cursor cursor =new sqliteOpen(threeMenuInspectActivity.this).getWritableDatabase().rawQuery("select * from final" , null);
<span style="white-space:pre"> </span>new dbToDataCsv(threeMenuInspectActivity.this,
<span style="white-space:pre"> </span>cursor, strName + ".csv")
<span style="white-space:pre"> </span>.ExportToDataCSV(file.getPath());
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>});
<span style="white-space:pre"> </span>builder.setPositiveButton("取消",
<span style="white-space:pre"> </span>new DialogInterface.OnClickListener() {
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public void onClick(DialogInterface dialog,
<span style="white-space:pre"> </span>int which) {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>});
<span style="white-space:pre"> </span>builder.create().show();
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>Log.v("final", rawInspectFinal.size()+"");
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>});
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>if (sqlName.equals("pressure_p2x")) {
<span style="white-space:pre"> </span>three_menu_inspect_TextView1.setText("P2X系列压力变送器造型及报价");
<span style="white-space:pre"> </span>}else if(sqlName.equals("pressure_p3x"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>three_menu_inspect_TextView1.setText("P3X系列压力变送器造型及报价");
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>else if(sqlName.equals("pressure_p4x"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>three_menu_inspect_TextView1.setText("P4X系列压力变送器造型及报价");
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>dbhelper=new sqlDbHelper(this);
<span style="white-space:pre"> </span>three_menu_inspect_listView=(ListView) findViewById(R.id.three_menu_inspect_listView);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>three_menu_inspect_listView.setAdapter(new myAdapter(this));
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>//
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>//Log.v("lwn", ":"+arrayList.toString());
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private void init() {
<span style="white-space:pre"> </span>if (T) {
<span style="white-space:pre"> </span>Intent intent = threeMenuInspectActivity.this.getIntent();
<span style="white-space:pre"> </span>sqlName = intent.getStringExtra("sqlName");
<span style="white-space:pre"> </span>Log.v("sqlName", sqlName);
<span style="white-space:pre"> </span>if (sqlName.equals("P2X系列")) {
<span style="white-space:pre"> </span>strName=sqlName;
<span style="white-space:pre"> </span>sqlName="pressure_p2x";
<span style="white-space:pre"> </span>}else if(sqlName.equals("P3X系列"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>strName=sqlName;
<span style="white-space:pre"> </span>sqlName="pressure_p3x";
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>else if(sqlName.equals("P4X系列"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>strName=sqlName;
<span style="white-space:pre"> </span>sqlName="pressure_p4x";
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>/*
<span style="white-space:pre"> </span>else if(sqlName.equals("PMD235型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmd235";
<span style="white-space:pre"> </span>}else if(sqlName.equals("FMD630型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_fmd630";
<span style="white-space:pre"> </span>}else if(sqlName.equals("FMD633型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_fmd633";
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>else if(sqlName.equals("PMC731型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc731";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMP731型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmp731";
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>else if(sqlName.equals("PMC631型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc631";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC635型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc635";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMP635型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmp635";
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>else if(sqlName.equals("PMC41型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc41";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC45型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc45";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMP41型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmp41";
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>else if(sqlName.equals("PMP45型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmp45";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMP46型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmp46";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMP48型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmp48";
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>else if(sqlName.equals("PMC133型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc133";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC133IZ型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc1331";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC134型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc134";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC134Z型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc134z";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC330型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc330";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC430Z型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc430z";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC531型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc531";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC534型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc534";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC534Z型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc534z";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC535型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc535";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC535Z型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc535z";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC536型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc536";
<span style="white-space:pre"> </span>}else if(sqlName.equals("PMC536Z型"))
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>sqlName="pressure_pmc536z";
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>*/
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>public String getDate() {
<span style="white-space:pre"> </span>Date date = new Date();
<span style="white-space:pre"> </span>SimpleDateFormat simple = new SimpleDateFormat("HH_mm_ss");
<span style="white-space:pre"> </span>String dateTime = simple.format(date);
<span style="white-space:pre"> </span>return dateTime;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>public class myAdapter extends BaseAdapter
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>private Context mconContext;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>public myAdapter(Context context) {
<span style="white-space:pre"> </span>this.mconContext=context;
<span style="white-space:pre"> </span>List<Dict_type> dictItem = new DictDaoImpl(context).getDictItem("");
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public int getCount() {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>return dicts_type.length;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public Object getItem(int arg0) {
<span style="white-space:pre"> </span>// TODO Auto-generated method stub
<span style="white-space:pre"> </span>return null;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public long getItemId(int arg0) {
<span style="white-space:pre"> </span>// TODO Auto-generated method stub
<span style="white-space:pre"> </span>return 0;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public View getView(int possition1, View view, ViewGroup parent) {
<span style="white-space:pre"> </span>viewHolder holder;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>Log.v("zy", "lwn+getView");
<span style="white-space:pre"> </span>if(view==null)
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>LayoutInflater lf = (LayoutInflater) threeMenuInspectActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
<span style="white-space:pre"> </span>view= lf.inflate(R.layout.three_menu_layout_inspect, null);
<span style="white-space:pre"> </span>holder=new viewHolder();
<span style="white-space:pre"> </span>holder.three_menu_layout_inspect_textView=(TextView)view.findViewById(R.id.three_menu_layout_inspect_textView);
<span style="white-space:pre"> </span>holder.three_menu_layout_inspect_spinner=(Spinner)view.findViewById(R.id.three_menu_layout_inspect_spinner);
<span style="white-space:pre"> </span>holder.three_menu_layout_inspect_editText=(TextView) view.findViewById(R.id.three_menu_layout_inspect_editText);
<span style="white-space:pre"> </span>view.setTag(holder);
<span style="white-space:pre"> </span>}else{
<span style="white-space:pre"> </span>holder=(viewHolder) view.getTag();
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>holder.three_menu_layout_inspect_textView.setText( dicts_type[possition1]);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>spinner(possition1, holder);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>holder.three_menu_layout_inspect_editText.setText(three_menu_layout_inspect_spinner_textView1);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>return view;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>public void product()
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>boolean BIAOZHI=true;
<span style="white-space:pre"> </span>private void spinner(final int possition, viewHolder holder) {
<span style="white-space:pre"> </span>datalist=new ArrayList<String>();//此处的数据就是从数据库查出来
<span style="white-space:pre"> </span>List<Dict_data> list_data_a = new ArrayList<Dict_data>();
<span style="white-space:pre"> </span>list_data_a=new DictDaoData(threeMenuInspectActivity.this).getDictItem(dicts_type[possition]);
<span style="white-space:pre"> </span>datalist.add(0," ");
<span style="white-space:pre"> </span>for (Dict_data retList : list_data_a) {
<span style="white-space:pre"> </span>datalist.add(retList.getData());
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span> final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(threeMenuInspectActivity.this, android.R.layout.simple_spinner_item,datalist);
<span style="white-space:pre"> </span>arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>holder.three_menu_layout_inspect_spinner.setAdapter( arrayAdapter);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>holder.three_menu_layout_inspect_spinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public void onItemSelected(AdapterView<?> parent, View view,
<span style="white-space:pre"> </span>int position, long id) {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>//单击选中的这个然后将内容设置给后面的editText,根据三个字段的值来判断第四个字段的值,字段直接在view下面能娶到
<span style="white-space:pre"> </span>String item =(String)arrayAdapter.getItem(position);//获取每个条目
<span style="white-space:pre"> </span>ViewParent parent2 = parent.getParent();//获取父类控件
<span style="white-space:pre"> </span>TextView tt = (TextView) ((LinearLayout) parent2).findViewById(R.id.three_menu_layout_inspect_textView);//将它转型
<span style="white-space:pre"> </span>String str1 = tt.getText().toString().trim();//取出空格
<span style="white-space:pre"> </span>if (item.equals(" ")) {
<span style="white-space:pre"> </span>three_menu_layout_inspect_spinner_textView1=" ";
<span style="white-space:pre"> </span>a=" ";
<span style="white-space:pre"> </span>}else {
<span style="white-space:pre"> </span>three_menu_layout_inspect_spinner_textView1=item.split(" ")[0].toString().trim();//分割字符串
<span style="white-space:pre"> </span>a=item.substring(three_menu_layout_inspect_spinner_textView1.length(), item.length());//分割
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span> //a = a.trim();
<span style="white-space:pre"> </span> while(a.startsWith(" ")){
<span style="white-space:pre"> </span> a = a.substring(1,a.length()).trim();
<span style="white-space:pre"> </span> }
<span style="white-space:pre"> </span> while(a.endsWith(" ")){
<span style="white-space:pre"> </span> a = a.substring(0,a.length()-1).trim();
<span style="white-space:pre"> </span> }
<span style="white-space:pre"> </span>Log.v("ai", three_menu_layout_inspect_spinner_textView1);
<span style="white-space:pre"> </span>dbhelper.updateSpinner_str(three_menu_layout_inspect_spinner_textView1,possition);
<span style="white-space:pre"> </span>ArrayList<String> array_price_str = dbhelper.rawInspectSpinner_str();
<span style="white-space:pre"> </span>String sum_str="";
<span style="white-space:pre"> </span>String [] a2=new String[dicts_type.length];
<span style="white-space:pre"> </span>for(int i = 0;i < dicts_type.length; i ++){
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>if (i==1) {
<span style="white-space:pre"> </span>sum_str=sum_str+"-";
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>a2[i]=array_price_str.get(i);
<span style="white-space:pre"> </span>sum_str=sum_str+""+a2[i];
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>three_menu_inspect_editText1.setText(sum_str+"");
<span style="white-space:pre"> </span>editText= (TextView) ((LinearLayout) parent2).findViewById(R.id.three_menu_layout_inspect_editText);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>String item2=<span style="white-space:pre"> </span>editText.getText().toString();
<span style="white-space:pre"> </span>rawInspectEditSql = dbhelper.rawInspectEditSql(sqlName,str1,three_menu_layout_inspect_spinner_textView1,a);//根据条件查询出来的<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>if (rawInspectEditSql.equals("另议")) {
<span style="white-space:pre"> </span>editText.setText("另议");
<span style="white-space:pre"> </span>dbhelper.updateSpinner("另议",possition);
<span style="white-space:pre"> </span>}else{
<span style="white-space:pre"> </span>int lwn = Integer.parseInt(rawInspectEditSql+"0");
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>//Log.v("cao", "rawInspectEditSql="+rawInspectEditSql+"lwn");
<span style="white-space:pre"> </span>editText.setText(lwn/10+"");
<span style="white-space:pre"> </span>dbhelper.updateSpinner(lwn/10+"",possition);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>//dbhelper.updateFinal(str1, "lwn", "lwn", "lwn", possition+1);
<span style="white-space:pre"> </span>dbhelper.updateFinal(str1, three_menu_layout_inspect_spinner_textView1, a, editText.getText().toString(),possition+1);
<span style="white-space:pre"> </span>ArrayList<String> array_price = dbhelper.rawInspectSpinner();
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>//方法4
<span style="white-space:pre"> </span>int sum = 0 ;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>int[] a1=new int[dicts_type.length];
<span style="white-space:pre"> </span>for(int i = 0;i < dicts_type.length; i ++){
<span style="white-space:pre"> </span>//先遍历每个值,看看有没有"另议",有了就跳出不循环,
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>if (array_price.get(i).equals("另议")) {
<span style="white-space:pre"> </span>a1[i]= -1000000;
<span style="white-space:pre"> </span>Log.v("cao", "else"+sum);
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>else {
<span style="white-space:pre"> </span>a1[i]=Integer.parseInt(array_price.get(i));
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>sum=sum+a1[i];
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>Log.v("sum", "sum="+sum);
<span style="white-space:pre"> </span>if (sum<0) {
<span style="white-space:pre"> </span>three_menu_inspect_editText2.setText("另议");
<span style="white-space:pre"> </span>}else{
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>three_menu_inspect_editText2.setText(sum+"");
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>//找到每个控件,执行存储到数据库的方法
<span style="white-space:pre"> </span>//dbhelper.deleteFinal();
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public void onNothingSelected(AdapterView<?> arg0) {
<span style="white-space:pre"> </span>//不按 的话不做任何处理
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>});
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>public class viewHolder
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>TextView three_menu_layout_inspect_textView;
<span style="white-space:pre"> </span>Spinner three_menu_layout_inspect_spinner;
<span style="white-space:pre"> </span>TextView three_menu_layout_inspect_editText;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>public class DictDaoData{
<span style="white-space:pre"> </span>private Context context;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>public DictDaoData(Context context) {
<span style="white-space:pre"> </span>this.context = context;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>public List<Dict_data> getDictItem(String str) {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>//只把type这个类型这删除重复元素
<span style="white-space:pre"> </span>list_data = dbhelper.rawInspectSpinnerSql(sqlName,str);//查询数据库的type
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>Object[] dictss_data = list_data.toArray(new Object[list_data
<span style="white-space:pre"> </span>.size()]);
<span style="white-space:pre"> </span>//转为数组
<span style="white-space:pre"> </span>String[] dicts_data = new String[dictss_data.length];
<span style="white-space:pre"> </span>for (int i = 0; i < dictss_data.length; i++) {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>dicts_data[i] = (String) dictss_data[i];
<span style="white-space:pre"> </span>}<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>List<Dict_data> retList = new ArrayList<Dict_data>();
<span style="white-space:pre"> </span>for (int j = 0; j < dicts_data.length; j++) {
<span style="white-space:pre"> </span>Dict_data dict = new Dict_data();
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>dict.setData(dicts_data[j]);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>retList.add(dict);
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>return retList;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>//这个类中的方法能返回数量,我只要type去重复之后的
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>public class DictDaoImpl {
<span style="white-space:pre"> </span>private Context context;
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>public DictDaoImpl(Context context) {
<span style="white-space:pre"> </span>this.context = context;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>/*
<span style="white-space:pre"> </span> * 如果这个对象不存在
<span style="white-space:pre"> </span> */
<span style="white-space:pre"> </span>public boolean isExist() {
<span style="white-space:pre"> </span>return false;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>//这个类的这个方法,是返回一个list集合
<span style="white-space:pre"> </span>public List<Dict_type> getDictItem(String dictId) {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>//只把type这个类型这删除重复元素
<span style="white-space:pre"> </span>list_type = dbhelper.rawMyQueryType(sqlName);//查询数据库的type
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>for (int i = 0; i < list_type.size() - 1; i++) {
<span style="white-space:pre"> </span> for (int j = list_type.size() - 1; j > i; j--) {
<span style="white-space:pre"> </span> if(list_type.get(j).toString().equals(list_type.get(i).toString())){
<span style="white-space:pre"> </span> <span style="white-space:pre"> </span>list_type.remove(j);
<span style="white-space:pre"> </span> }
<span style="white-space:pre"> </span> }
<span style="white-space:pre"> </span> } //去重
<span style="white-space:pre"> </span>Object[] dictss_type = list_type.toArray(new Object[list_type
<span style="white-space:pre"> </span>.size()]);
<span style="white-space:pre"> </span>//转为数组
<span style="white-space:pre"> </span>dicts_type= new String[dictss_type.length];
<span style="white-space:pre"> </span>for (int i = 0; i < dictss_type.length; i++) {
<span style="white-space:pre"> </span>dicts_type[i] = (String) dictss_type[i];
<span style="white-space:pre"> </span>}<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>List<Dict_type> retList = new ArrayList<Dict_type>();
<span style="white-space:pre"> </span>for (int j = 0; j < dicts_type.length; j++) {
<span style="white-space:pre"> </span>Dict_type dict = new Dict_type();
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>dict.setType(dicts_type[j]);
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>retList.add(dict);
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>return retList;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>@Override
<span style="white-space:pre"> </span>public boolean onKeyDown(int keyCode, KeyEvent event) {
<span style="white-space:pre"> </span>// TODO Auto-generated method stub
<span style="white-space:pre"> </span>if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>threeMenuInspectActivity.this.finish();
<span style="white-space:pre"> </span>Intent intent=new Intent(threeMenuInspectActivity.this,twoMenuPressureActivity.class);
<span style="white-space:pre"> </span>startActivity(intent);
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>return true;
<span style="white-space:pre"> </span>}
<span style="white-space:pre"> </span>
}
- 剩下无关紧要的布局:
一级:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="25sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/firstMenuActivity_textView_1" />
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:layout_weight="1"
android:id="@+id/button_first_01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/firstMenuActivity_button_1" />
<Button
android:layout_weight="1"
android:id="@+id/button_first_02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/firstMenuActivity_button_2" />
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:layout_weight="1"
android:id="@+id/button_first_03"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/firstMenuActivity_button_3" />
<Button
android:layout_weight="1"
android:id="@+id/button_first_04"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/firstMenuActivity_button_4" />
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:layout_weight="1"
android:id="@+id/button_first_05"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/firstMenuActivity_button_5" />
<Button
android:layout_weight="1"
android:id="@+id/button_first_06"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/firstMenuActivity_button_6" />
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:layout_weight="1"
android:id="@+id/button_first_07"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/firstMenuActivity_button_7" />
<Button
android:layout_weight="1"
android:id="@+id/button_first_08"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/firstMenuActivity_button_8" />
</LinearLayout>
</LinearLayout>
二级:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_textView_1"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/button_two_one_01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_one_1" />
<Button
android:id="@+id/button_two_one_02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_one_2" />
<Button
android:id="@+id/button_two_one_03"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_one_3" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_textView_2"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/button_two_two_01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_two_1" />
<Button
android:id="@+id/button_two_two_02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_two_2" />
<Button
android:id="@+id/button_two_two_03"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_two_3" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_textView_3"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/button_two_three_01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_three_1" />
<Button
android:id="@+id/button_two_three_02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_three_2" />
<Button
android:id="@+id/button_two_three_03"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_three_3" />
</LinearLayout>
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/button_two_three_04"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_three_4" />
<Button
android:id="@+id/button_two_three_05"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_three_5" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_textView_4"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/button_two_four_01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_four_1" />
<Button
android:id="@+id/button_two_four_02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_four_2" />
<Button
android:id="@+id/button_two_four_03"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_four_3" />
</LinearLayout>
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/button_two_four_04"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_four_4" />
<Button
android:id="@+id/button_two_four_05"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_four_5" />
<Button
android:id="@+id/button_two_four_06"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_four_6" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_textView_5"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/button_two_five_01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_1" />
<Button
android:id="@+id/button_two_five_02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_2" />
<Button
android:id="@+id/button_two_five_03"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_3" />
<Button
android:id="@+id/button_two_five_04"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_4" />
</LinearLayout>
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button_two_five_05"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_5" />
<Button
android:id="@+id/button_two_five_06"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_6" />
<Button
android:id="@+id/button_two_five_07"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_7" />
<Button
android:id="@+id/button_two_five_08"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_8" />
</LinearLayout>
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button_two_five_09"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_9" />
<Button
android:id="@+id/button_two_five_10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_10" />
<Button
android:id="@+id/button_two_five_11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_11" />
<Button
android:id="@+id/button_two_five_12"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_12" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/button_two_five_13"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_five_13" />
<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_textView_6"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/button_two_sex_01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_sex_1" />
<Button
android:id="@+id/button_two_sex_02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/twoMenuPressureActivity_button_sex_2" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
三级:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:textSize="15sp"
android:textStyle="bold"
android:gravity="center"
android:id="@+id/three_menu_inspect_TextView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<Button
android:id="@+id/three_menu_inspect_button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="导出" />
</LinearLayout>
</LinearLayout>
<ListView
android:layout_weight="1"
android:id="@+id/three_menu_inspect_listView"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/three_menu_inspect_textView1" />
<TextView
android:id="@+id/three_menu_inspect_editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/three_menu_inspect_textView2" />
<TextView
android:id="@+id/three_menu_inspect_editText2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/three_menu_inspect_textView3" />
</LinearLayout>
</LinearLayout>
</LinearLayout>