我有一个列表视图,其中包含已从Web服务填充的值。所有这一切工作正常,如预期。列表视图由标签和带有数值的edittext组成。理想情况下,这个值应该是可编辑的,问题是在我编辑值并滚动列表视图后,数字返回到初始值(假设初始值为10,我编辑为20,滚动列表返回10)< / p>
适配器如下:我如何解决此问题
package com.example.houssam.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView) findViewById(R.id.hello);
Connection connection = null;
try {// Load the Oracle JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
// Create a connection to the database
String serverName = "localhost";
String serverPort = "1521";
String sid = "orcl";
String url = "jdbc:oracle:thin:@" + serverName + ":" + serverPort + ":" + sid;
String username = "bmanager";
String password = "b";
connection = DriverManager.getConnection(url, username, password);
tv.setText("Successfully Connected to the database!");
}
catch (SQLException e) {
tv.setText("Could not connect to the database " + e.getMessage());
}
catch (ClassNotFoundException e) {
tv.setText("Could not find the database driver " + e.getMessage());
}
}
}
}
答案 0 :(得分:1)
您要将新文本保存在临时数组中,
arrTemp[holder.ref]=s.toString();
但您正在显示数据数组中的teste
holder.sku_quantity.setText(skus.get(V_SKUs.KEY_SKU_QTY));
因此,每次重新创建视图时,都会显示旧文本,而不是新编辑的文本
您需要检查要显示的临时数组中是否有新数据,而不是原始数据