Ich habe eine Listenansicht mit 3 Text im Listenelement bearbeiten. Der Status der Eingabedatei für den Bearbeitungstext bleibt nicht an der Position des Elements fixiert.EditText in listView nicht in der Lage, die Eingabe zu halten, Android?
Ich habe ein Array erstellt, um den Wert zu speichern, aber es repliziert den Wert im gesamten Bearbeitungstext.
Das ist meine Adapterklasse
public class OrderAdapter extends BaseAdapter {
private ArrayList<POJOOrder> assetArrayList;
private String[] agreedVolume, agreedSalesParty, agreedSalesMgr;
public OrderAdapter(ArrayList<POJOOrder> assetArrayList) {
this.assetArrayList = assetArrayList;
agreedVolume = new String[assetArrayList.size()];
agreedSalesParty = new String[assetArrayList.size()];
agreedSalesMgr = new String[assetArrayList.size()];
}
@Override
public int getCount() {
return assetArrayList.size();
}
@Override
public Object getItem(int position) {
return assetArrayList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View vi = convertView;
final ViewHolder holder;
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater)
parent.getContext().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
vi = mInflater.inflate(R.layout.element_order, null);
holder = new ViewHolder();
holder.tvItem = (TextView) vi.findViewById(R.id.textViewItem);
holder.tvPlanned = (TextView) vi.findViewById(R.id.textViewPlanned);
holder.tvPlannedParty = (TextView) vi.findViewById(R.id.textViewPalnnedParty);
holder.tvPlannedMgr = (TextView) vi.findViewById(R.id.textViewPlannedMgr);
holder.etAgreed = (EditText) vi.findViewById(R.id.editTextAgreed);
holder.etAgreedParty = (EditText) vi.findViewById(R.id.editTextAgreedParty);
holder.etAgreeMgr = (EditText) vi.findViewById(R.id.editTextAgreedMgr);
// holder.etAgreed.setTag(position);
// holder.etAgreedParty.setTag(position);
// holder.etAgreeMgr.setTag(position);
vi.setTag(holder);
} else
holder = (ViewHolder) vi.getTag();
holder.number = position;
holder.tvItem.setText(assetArrayList.get(position).getBrandWith_SKU());
holder.tvPlanned.setText(assetArrayList.get(position).getPlannedVolume() + " CS");
holder.tvPlannedParty.setText(assetArrayList.get(position).getPlannedSalesPromoParty() + "");
holder.tvPlannedMgr.setText(assetArrayList.get(position).getPlannedSalesPromoMgr() + "");
if (agreedVolume[holder.number] != null) {
holder.etAgreed.setText("" + agreedVolume[position]);
}
if (agreedSalesParty[position] != null) {
holder.etAgreedParty.setText("" + agreedSalesParty[position]);
}
if (agreedSalesMgr[position] != null) {
holder.etAgreeMgr.setText("" + agreedSalesMgr[position]);
}
holder.etAgreed.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
Log.e("position", holder.number + "");
agreedVolume[holder.number] = s.toString();
}
});
holder.etAgreedParty.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
agreedSalesParty[holder.number] = s.toString();
}
});
holder.etAgreeMgr.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
agreedSalesMgr[holder.number] = s.toString();
}
});
return vi;
}
private static class ViewHolder {
private TextView tvItem, tvPlanned, tvPlannedParty, tvPlannedMgr;
private EditText etAgreed, etAgreedParty, etAgreeMgr;
private int number;
}
}
POJOOrder mit Getter und Setter nur pojo Klasse ist
public class POJOOrder {
private int BrandId;
private String BrandWith_SKU;
private int SKU_Id;
private int PlannedVolume;
private int PlannedSalesPromoParty;
private int PlannedSalesPromoMgr;
public POJOOrder(int brandId, String brandWith_SKU, int SKU_Id, int plannedVolume, int plannedSalesPromoParty, int plannedSalesPromoMgr) {
BrandId = brandId;
BrandWith_SKU = brandWith_SKU;
this.SKU_Id = SKU_Id;
PlannedVolume = plannedVolume;
PlannedSalesPromoParty = plannedSalesPromoParty;
PlannedSalesPromoMgr = plannedSalesPromoMgr;
}
public int getBrandId() {
return BrandId;
}
public String getBrandWith_SKU() {
return BrandWith_SKU;
}
public int getSKU_Id() {
return SKU_Id;
}
public int getPlannedVolume() {
return PlannedVolume;
}
public int getPlannedSalesPromoParty() {
return PlannedSalesPromoParty;
}
public int getPlannedSalesPromoMgr() {
return PlannedSalesPromoMgr;
}
}
Dies ist die Liste Element XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewItem"
android:layout_width="120dp"
android:layout_height="60dp"
android:gravity="center"
android:text="Item Code"
android:textColor="@android:color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/textViewPlanned"
android:layout_width="90dp"
android:layout_height="60dp"
android:gravity="center"
android:text="0 CS "
android:textColor="@android:color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/textViewPalnnedParty"
android:layout_width="90dp"
android:layout_height="60dp"
android:gravity="center"
android:text="0"
android:textColor="@android:color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/textViewPlannedMgr"
android:layout_width="90dp"
android:layout_height="60dp"
android:gravity="center"
android:text="0"
android:textColor="@android:color/black"
android:textSize="15sp" />
<EditText
android:id="@+id/editTextAgreed"
android:layout_width="80dp"
android:layout_height="60dp"
android:gravity="center"
android:hint="000"
android:inputType="number"
android:maxLength="3"
android:textColor="@android:color/black"
android:textSize="15sp" />
<EditText
android:id="@+id/editTextAgreedParty"
android:layout_width="80dp"
android:layout_height="60dp"
android:gravity="center"
android:hint="000"
android:inputType="number"
android:maxLength="3"
android:textColor="@android:color/black"
android:textSize="15sp" />
<EditText
android:id="@+id/editTextAgreedMgr"
android:layout_width="80dp"
android:layout_height="60dp"
android:gravity="center"
android:hint="000"
android:inputType="number"
android:maxLength="3"
android:textColor="@android:color/black"
android:textSize="15sp" />
</LinearLayout>
Können Sie auch Ihre 'POJOOrder.java' und' element_order.xml' anzeigen? – x0r
@ x0r aktualisiert die Frage – WISHY
Können Sie Ihre App Screenshot hochladen? Ich kann nicht verstehen, wo es repliziert. –