在我的应用程序中,我使用 CursorAdapter。这将显示一个列表,它是 RelativeLayout 的一部分。此列表包括几个元素(TextView、Button、EditText)。EditText 通常不会出现在屏幕上。问题:我将任何数据导入 EditText 并滚动屏幕。此刻,我在另一个 EditText 中看到了导入的数据。或者:
另一个案例。有3个EditText。我使用虚拟键盘(例如使用第二个editText)。我将数据输入到编辑文本中。按下返回按钮。数据转到下面的编辑文本。(所以数据转到第三个Edit Text)这里是CursorAdapter代码:
class OOSListadapter extends CursorAdapter{
OOSListadapter(Cursor c){
super(OOS.this,c);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
OOSRow newRow = (OOSRow)view.getTag();
newRow.populateRow(cursor);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater inflater=getLayoutInflater();
View row=inflater.inflate(R.layout.oos_row, parent, false);
OOSRow newRow = new OOSRow(row);
row.setTag(newRow);
return (row);
}
}
这是我的应用程序列表中的一行。
class OOSRow {
private TextView row_Action = null;;
private TextView row_Must = null;;
private TextView row_Lack = null;;
private TextView row_itemName = null;;
private EditText row_price = null;;
private Button row_detail = null;
private View row = null;
OOSRow (View row){
this.row = row;
row_Action = (TextView)row.findViewById(R.id.oos_row_SignalA);
row_Must = (TextView)row.findViewById(R.id.oos_row_SignalK);
row_Lack = (TextView)row.findViewById(R.id.oos_row_SignalO);
row_itemName = (TextView)row.findViewById(R.id.oos_row_itemLabel);
row_price = (EditText)row.findViewById(R.id.oos_row_EditText);
row_detail = (Button)row.findViewById(R.id.oos_row_detailButton);
}
void populateRow (Cursor c){
Cursor specCursor = dbLoc.Query("SELECT PRICE, LACK, ORDERED FROM ORDERED WHERE ITEMID='"+ c.getString(1) +"'", null);
specCursor.moveToFirst();
row_itemName.setText(c.getString(2));
row_itemName.setContentDescription(c.getString(1));
if (specCursor.getString(1).toString().equals("Y")){
row_itemName.setBackgroundColor(Color.parseColor("#FF0000"));
row_itemName.setTextColor(Color.parseColor("#FFFFFF"));
}else{
row_itemName.setBackgroundColor(Color.parseColor("#000000"));
row_itemName.setTextColor(Color.parseColor("#FFFFFF"));
}
row_itemName.setOnClickListener(SelectedLackItem);
if (c.getString(5).toString().equals("I")){
row_Action.setTextColor(Color.parseColor("#000000"));
row_Action.setBackgroundColor(Color.parseColor("#FF0000"));
}
else{
row_Action.setTextColor(Color.parseColor("#FFFFFF"));
row_Action.setBackgroundColor(Color.parseColor("#000000"));
}
if (c.getString(4).toString().equals("I")){
row_Must.setTextColor(Color.parseColor("#000000"));
row_Must.setBackgroundColor(Color.parseColor("#00FF00"));
}
else{
row_Must.setTextColor(Color.parseColor("#FFFFFF"));
row_Must.setBackgroundColor(Color.parseColor("#000000"));
}
specCursor = dbLoc.Query("SELECT LACK FROM LASTORDERED WHERE ITEMID='"+c.getString(1)+"' AND COMPANYID ='"+dbLoc.GetCompanyId()+"'", null);
if (specCursor.moveToFirst())
{
if (specCursor.getString(0).toString().equals("I")){
row_Lack.setTextColor(Color.parseColor("#000000"));
row_Lack.setBackgroundColor(Color.parseColor("#0000FF"));
}else{
row_Lack.setTextColor(Color.parseColor("#FFFFFF"));
row_Lack.setBackgroundColor(Color.parseColor("#000000"));
}
}
row_detail.setOnClickListener(OpenDetailScreenButton);
row_detail.setContentDescription(c.getString(1));
row_price.setContentDescription(c.getString(1));
row_price.setInputType(0);
/*row_price.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
row_price.setInputType(InputType.TYPE_CLASS_NUMBER);
}
@Override
public void afterTextChanged(Editable s) {
}
});*/
specCursor.close();
specCursor = null;
}
}
还有一些图片:
后退按钮:
任何想法?