/*
* Copyright 2009 eFANsoftware
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package efan.zz.android.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Bundle;
import android.text.InputType;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TableLayout;
import android.widget.TableRow;
import efan.zz.android.R;
import efan.zz.android.ZZ;
import efan.zz.android.common.android.IdentifiedAutoCompleteTextView;
import efan.zz.android.common.android.IdentifiedStringAdapter;
import efan.zz.android.util.ZzUtil;
/*
* Implementation decision: copy&paste RxRecipeDetail.java code,
* Only pass rx_recipe id as parameter,
* To query the DB again: if it's slow to user,
* the query must be optimised anyway otherwise it's slow in RxRecipeDetail page already!
*/
public class RxRecipeDetailEdit extends Activity
{
private EditText nameView;
private EditText aliasView;
private EditText keyCodeView;
private EditText descView;
private TableLayout medTab;
private static IdentifiedStringAdapter medsAdapter;
private String rxId0;
private String name0;
private static OnClickListener insertBtnListener, delBtnListener;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.rx_recipe_detail_edit);
init();
initSaveAction();
initCancelAction();
}
private void init()
{
final Intent intent = getIntent();
rxId0 = Uri.decode(intent.getDataString());
// query DB for detail...
final String sql = getResources().getString(R.string.SQL_QUERY_RX_RECIPE_BY_ID);
final Cursor cursor = ZZ.db.rawQuery(sql, new String[]{rxId0});
String name = null;
String desc = null;
String alias = null;
String keyCode = null;
try
{
cursor.moveToNext();
name = cursor.getString(0);
keyCode = cursor.getString(1);
desc = cursor.getString(2);
alias = cursor.getString(3);
}
finally
{
cursor.close();
}
nameView = (EditText) findViewById(R.id.rxFormulaName);
nameView.setText(name);
name0 = name;
aliasView = (EditText) findViewById(R.id.rxFormulaAlias);
aliasView.setText(alias);
keyCodeView = (EditText) findViewById(R.id.rxFormulaKeyCode);
keyCodeView.setText(keyCode);
descView = (EditText) findViewById(R.id.rxFormulaDesc);
descView.setText(desc.replace("\\n", "\n"));
}
@Override
public void onStart()
{
super.onStart();
// query medicines & display in table
loadMedsAutoCompAdapter();
initInsertDelListeners();
medTab = (TableLayout) findViewById(R.id.rxFormulaDetailTab);
loadRxMedicines(rxId0, medTab);
// Add empty line at the end for adding medicines to the end
TableRow nilRow = new TableRow(this);
Button lastInsertBtn = new Button(this);
lastInsertBtn.setGravity(Gravity.CENTER | Gravity.LEFT);
lastInsertBtn.setText("+");
lastInsertBtn.setOnClickListener(insertBtnListener);
EditText nilText = new EditText(this);
nilText.setEnabled(false);
nilText.setText("...");
nilRow.addView(lastInsertBtn);
nilRow.addView(nilText);
medTab.addView(nilRow);
}
private void loadMedsAutoCompAdapter()
{
if (medsAdapter != null)
return;
medsAdapter = new IdentifiedStringAdapter(this, android.R.layout.simple_dropdown_item_1line);
final String sql = getResources().getString(R.string.SQL_LOAD_MEDICINE_FOR_AC);
medsAdapter.loadNameOrKeyAutoCompAdapter(sql);
}
private void initInsertDelListeners()
{
insertBtnListener = new OnClickListener()
{
public void onClick(View v)
{
((TableRow) v.getParent()).requestFocus();
final TableRow newRow = buildTableRow(-1, "", "", false);
final View currentRow = medTab.getFocusedChild();
final int idx = medTab.indexOfChild(currentRow);
medTab.addView(newRow, idx);
newRow.requestFocus();
}
};
delBtnListener = new OnClickListener()
{
public void onClick(View v)
{
((TableRow) v.getParent()).requestFocus();
final View currentRow = medTab.getFocusedChild();
medTab.removeView(currentRow);
}
};
}
private void loadRxMedicines(final String rxId, final TableLayout medTab)
{
final String sql = getResources().getString(R.string.SQL_LOAD_RX_MEDICINES_BY_ID);
final Cursor cursor = ZZ.db.rawQuery(sql, new String[]{rxId});
try
{
while (cursor.moveToNext())
{
int id = cursor.getInt(0);
String name = cursor.getString(1);
String quantity = cursor.getString(2);
boolean isOptional = "Y".equals(cursor.getString(4));
TableRow row = buildTableRow(id, name, quantity, isOptional);
medTab.addView(row);
}
}
finally
{
cursor.close();
}
}
private TableRow buildTableRow(int id, String name, String quantity, boolean isOptional)
{
Button insertBtn = new Button(this);
insertBtn.setGravity(Gravity.CENTER | Gravity.CENTER);
insertBtn.setText("+");
insertBtn.setOnClickListener(insertBtnListener);
final IdentifiedAutoCompleteTextView medNameText = new IdentifiedAutoCompleteTextView(this);
medNameText.setValueId(id);
final EditText qtyText = new EditText(this);
final StringBuilder isClicked = new StringBuilder();
medNameText.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
medNameText.setValueId(medsAdapter.getItem(position).id);
isClicked.append(Boolean.TRUE);
qtyText.requestFocus();
}
});
medNameText.setThreshold(1);
medNameText.setGravity(Gravity.CENTER | Gravity.LEFT);
medNameText.setAdapter(medsAdapter);
final StringBuilder nameStr0 = new StringBuilder();
medNameText.setOnFocusChangeListener(new OnFocusChangeListener()
{
public void onFocusChange(View v, boolean hasFocus)
{
String nameVal0 = medNameText.getText().toString();
if (hasFocus)
{
nameStr0.replace(0, nameStr0.length(), nameVal0);
if (! medsAdapter.isReady())
ZzUtil.doWait(medsAdapter);
medNameText.setText("");
ZZ.inputMethodMgr.hideSoftInputFromWindow(v.getWindowToken(), 0);
medNameText.showDropDown();
isClicked.delete(0, isClicked.length());
}
else
{
medNameText.dismissDropDown();
if (isClicked.length() == 0)
{
medNameText.setText(nameStr0.toString());
}
}
}
});
medNameText.setText(name);
qtyText.setInputType(InputType.TYPE_CLASS_NUMBER);
qtyTex
没有合适的资源?快使用搜索试试~ 我知道了~
Android(源码)zz-doctor中医大夫助理信息系统.rar
共116个文件
svn-base:56个
java:17个
xml:15个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 137 浏览量
2023-02-03
10:39:34
上传
评论
收藏 565KB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
Android(源码)zz-doctor中医大夫助理信息系统.rar (116个子文件)
pre-pub-test.bat 175B
adb-run.bat 87B
.classpath 353B
wc.db 78KB
entries 3B
format 3B
logo_tcm_rx.gif 2KB
RxRecipeDetailEdit.java 13KB
WelcomeRxRecipeQuery.java 7KB
RxRecipeDetail.java 6KB
MedicineQuery.java 5KB
MedicineDetail.java 4KB
DbHelper.java 3KB
IdentifiedStringAdapter.java 3KB
ZzUtil.java 2KB
RecipeSQLBuilder.java 2KB
MedicineSQLBuilder.java 2KB
RecipeMedicineMapSQLBuilder.java 2KB
SubjectSQLBuilder.java 2KB
ZZ.java 2KB
IdentifiedAutoCompleteTextView.java 1KB
SQLBuilder.java 1KB
UnitAdapter.java 948B
IdentifiedString.java 883B
zz_icon.jpeg 3KB
alert_dialog_icon.png 4KB
logo_tcm_medicine.png 3KB
icon_menu_about.png 2KB
icon_menu_home.png 1KB
org.eclipse.core.resources.prefs 88B
.project 805B
default.properties 469B
signjar.sh 149B
adb.sh 87B
zz_data_medicine.sql 328KB
zz_data_recipe_medicine_map.sql 268KB
zz_data_recipe.sql 100KB
db_init.sql 17KB
zz_data_subject.sql 12KB
db_create.sql 3KB
db_create_v2.sql 475B
db_create_v3.sql 430B
db_clean.sql 265B
db_upgrade.sql 155B
0cf1c434ac7965a9af4856406d9adae20e7a591f.svn-base 354KB
73c4effc53139cbaad74dd3666457eebc1c794e3.svn-base 328KB
eb56f021c70ecd7282aa7e29272a9ec804995c65.svn-base 268KB
521a9fc83a160b6c63e7f33c3da44e1ff2daf4c4.svn-base 100KB
4d1e4483a0fc29070c0e50a3474bb08a9c40439e.svn-base 17KB
6702a6f289be07e8adc57a744576bbf90baeb87a.svn-base 13KB
c6f39f2c5a9068f23443f742bf60120f271a425f.svn-base 12KB
0332df093e0822458b3e02a384303281731ce90d.svn-base 7KB
b34df14631b4f0fe837c3838498dff55d3670c8a.svn-base 6KB
925b0cffb589e90f4b83bb084750a40380c0e7bb.svn-base 6KB
19e4b081776ff22c2ad69a4fa52048b420ec8773.svn-base 5KB
e9d4bae626fbc376458e69ec58fb4e3eb823b812.svn-base 5KB
def496af33c3f7210406e848488f149521998577.svn-base 4KB
02df3cc4ae57b8f3ff59dacad5ed7b9e62768100.svn-base 4KB
06f136123400b181304c3ef3ed46fd0a7ab355c7.svn-base 4KB
e3744e55ee32cc5e2353242386bccfea313c2791.svn-base 3KB
462a25844ca42f2d6f4980ec7c8ce75e5fd206cd.svn-base 3KB
61c7c7f57f96f112764e46ebcbf7ebe4561c6811.svn-base 3KB
36ea439fa34cbe754d7d48790bcc6cfba4cb4b7f.svn-base 3KB
6bdd09b94c71409d3d6436a5cf1db24e18eb7352.svn-base 3KB
c2928d723b510998be6480d9fa0e1fdbac388442.svn-base 3KB
a491d012e1ab5c4a5c97faa4062e86cad0100cec.svn-base 3KB
e5b1d4776ade9c80d241e540d75381ceccc4b4c1.svn-base 3KB
1d207351f89237941c39b79f573ca3a217eaa555.svn-base 3KB
9e774874b8192315afc8b50653b488fb9e0ae6d3.svn-base 2KB
3605200e1597b69969b5c613979d21c92f635fd6.svn-base 2KB
1d9b034a1e8739875bd4e704cebb963f0f9c9618.svn-base 2KB
e008d62dd3812f2c18f9e26fc5f3db4fa6adf1f9.svn-base 2KB
f3548e4332847e1722d43704ff08918e2fa4d9db.svn-base 2KB
0111420793c4669a7c4f548771129b1e245d8d3b.svn-base 2KB
011418f856180e6e7b1d3c1d7efe410f9a9d5622.svn-base 2KB
b0b1592540d2300afa135d264efdd0f22d4b18f0.svn-base 2KB
c4959f2cf5a2dd73c0452fbf49556f1fdaa6b13e.svn-base 2KB
9cc9d8440cce205ade9f2bbf0cae78463e2467f9.svn-base 1KB
6fba354ab7c66eefd36c705a241f305a27fab93f.svn-base 1KB
c5d3c20f101066a903003c897b76a8d2c513dfe7.svn-base 1KB
6b9a3a5dcdcb6443ebad456284788c5946d0072a.svn-base 1KB
fe6381e0b65f7640a69e765fd49c7f03889ac802.svn-base 1KB
0efa163ad606c4a0650bb92c73f690c5628e3091.svn-base 1KB
f1ec85918c0b629d844a14f9a6cab1b9b716ef66.svn-base 1KB
cc2b1a1adfb219c4a03ac2cfe5a6917ce9872d67.svn-base 948B
19eddbcaa9a363cd8172c22e3c09c289a78cabc2.svn-base 925B
196741e46ab416efecdfded870fbc30d8f237963.svn-base 890B
fb069fdf9c4b6fd513cbb7e9318f1e1684af444b.svn-base 890B
672e72d5b8540ae53bfdbc5e2cd8864ff63aa3bd.svn-base 883B
575048f5ce3e09ea7f0eee519dab0e427271927a.svn-base 805B
81d1c0e676bad39bfa146bf396cba5d288828b91.svn-base 475B
ddbf6eb3394da11c93ead8c6b017fb4758315343.svn-base 469B
8f3e3418acb36a29d861eae316145b931b24c4b3.svn-base 430B
ce6c595ef59f67cb2fcf0f41550df3fc5ade719f.svn-base 353B
b9c1d0fc7cb0b4326543b8c9560086dfef685687.svn-base 265B
120ae2282ffce751d732a95397713112df2c19e1.svn-base 175B
86767772e54d21f2f0be973f67ad4c41ad53f0b3.svn-base 155B
9736e59d6816f591f4492905823a5d26654655e8.svn-base 149B
b874c4694bcffa1e423e108a047ac9cdfdd71760.svn-base 88B
d50986c0e36f39563fd38e3eca34bdc0abf13218.svn-base 87B
共 116 条
- 1
- 2
资源评论
大富大贵7
- 粉丝: 393
- 资源: 8868
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功