は私が項目のリストを持って削除します。すなわち、入力されたのEditTextが、それは次のように
public class ProductAdapter extends ArrayAdapter<Product> {
private Context context;
private List<Product> mdata;
public ProductAdapter(Context context, List<Product> mdata) {
super(context, R.layout.act_item_product_adapter, mdata);
this.context = context;
this.mdata = mdata;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View item = LayoutInflater.from(context).inflate(R.layout.act_item_product_adapter,null);
TextView m_product_name = (TextView) item.findViewById(R.id.adapter_product_nameProduct);
TextView m_product_cost = (TextView) item.findViewById(R.id.adapter_product_cost);
TextView m_product_stock = (TextView) item.findViewById(R.id.adapter_product_stock);
EditText m_product_amount = (EditText) item.findViewById(R.id.adapter_product_amount);
ImageView m_product_photo = (ImageView) item.findViewById(R.id.adapter_product_photo);
m_product_name.setText(datos.get(position).getNombreProducto());
m_product_cost.setText(" Cost: " + String.format("%.2f",mdata.get(position).getCostSold()));
m_product_stock.setText(" Stock: " + Integer.toString(mdata.get(position).getStock()));
//m_product_amout.setText("0");
if (datos.get(position).getimagenProduct() != null){
byte[] decodedString = Base64.decode(mdata.get(position).getimagenProduct(), Base64.DEFAULT);
m_product_photo.setImageBitmap(BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length));
}
return item;
}
}
すべてがうまくいき、商品の情報を取得してリストに表示できますが、EditText(m_product_amount)に値を入力してアクティビティの別のオブジェクトをクリックすると、入力された数字は削除され、0のままですレイアウト内のデフォルトの番号です。
私は間違っていますか?
任意のアイデアや提案は
おかげで歓迎されている
=============質問更新===============
act_item_product_adapter.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/adapter_product_photo"
android:layout_width="80dp"
android:layout_height="80dp"
android:scaleType="centerInside"
android:background="@android:color/white"
android:cropToPadding="true"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_toRightOf="@id/adapter_product_photo"
android:id="@+id/linearLayout2">
<TextView
android:id="@+id/adapter_product_nameProducto"
android:layout_width = "match_parent"
android:layout_height = "37dp"
android:gravity="center"
android:textSize="20dp"
android:text="Name of product"/>
</LinearLayout>
<LinearLayout
android:layout_width= "170dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/linearLayout3"
android:layout_below="@+id/linearLayout2"
android:layout_toRightOf="@+id/adapter_product_photo"
android:layout_alignBottom="@+id/adapter_product_photo">
<TextView
android:id="@+id/adapter_product_cost"
android:layout_width = "170dp"
android:layout_height = "wrap_content"
android:text="cost"/>
<TextView
android:id="@+id/adapter_product_stock"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:text="stock"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_below="@+id/linearLayout2"
android:layout_toEndOf="@+id/linearLayout3"
android:layout_toRightOf="@+id/linearLayout3"
android:orientation="horizontal"
android:layout_alignBottom="@+id/linearLayout3">
<TextView
android:layout_width = "wrap_content"
android:layout_height = "match_parent"
android:gravity="center"
android:textSize="20dp"
android:text="Amount"/>
<EditText
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:inputType="number"
android:id="@+id/adapter_product_amount"
android:gravity="center"
android:text="0"/>
</LinearLayout>
</RelativeLayout>
私はあなたのレイアウト(複数可)を投稿示唆しています。 RecyclerViewを使うことをお勧めします。 –
さて、レイアウトで質問を更新します。ありがとう –
'EditText'フィールドに入力したものをどこで取得しているのかわかりません... – DigitalNinja