本文介绍了更新listview单行并再次显示在该列表视图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sqlite中使用edittext插入值并在listview中显示...之后我点击listview中的单行并且单行值再次显示在之前的edittext中..现在我想更新此edittext来自listview的价值。请有人告诉我怎么做?



< Intent intent = getIntent();

name = intent.getStringExtra(Name);

desg = intent.getStringExtra(Designation);



nam =(EditText)findViewById(R.id.NameEditText);

des =(EditText)findViewById(R.id.desgEditText);



nam.setText(name);

des.setText(desg);





insertButton.setOnClickListener(new View.OnClickListener(){

@Override

public void onClick(View v){

String employeename = nameEditText.getText()。toString();

int employeeno = Integer.parseInt(noEditText.getText()。toString());

字符串指定= desgEditText.getText()。toString();



dbhelper.insertIntoEmployeeTable(employeename,designation,employeeno);

Log .V(E mp_Name,employeename);

Log.v(Emp_no,String.valueOf(employeeno));

Log.v(Emp_Desg,名称);

Toast.makeText(getBaseContext(),你的数据被插入,Toast.LENGTH_SHORT).show();

}

});

updateButton.setOnClickListener(new View.OnClickListener(){

@Override

public void onClick(View v){

String employeename = nam.getText()。toString();

int employeeno = Integer.parseInt(noEditText.getText()。toString());

字符串指定= des.getText()。toString();



dbhelper.updateIntoEmployeeTable(employeename,designation,employeeno);

日志。 v(updateEmp_Name,employeename);

Log.v(updateEmp_no,String.valueOf(employeeno));

Log.v(updateEmp_Desg,名称);

Toast.makeText(getBaseContext(),你的数据已更新,Toast.LENGTH_SHORT)。show();





}

});

displayButton.setOnClickListener(new View.OnClickListener(){

@Override

public void onClick(View v){

Intent i = new Intent(MainActivity.this,GridViewActivity.class);

startActivity(i); //启动gridview活动以显示记录。

}

});

public void updateEmployeeTable(String employeename,String designation,int employeeno){

open();

ContentValues newValues = new ContentValues();

Log.v(UpdateEmployee,employeename +++指定);



newValues.put(fld_employeename ,employeename);

newValues.put(fld_designation,指定);

newValues.put(fld_employeeno,employeeno);



int update = db.update(tbl_employee,newValues,null,null);

db.close();

日志。 v(Update_Query,String.valueOf(update));

}



ArrayList

i am inserting the value using edittext in sqlite and displaying it in listview...after that i clicked on a single row in listview and that single row values are displaying in previous edittext again..now i want to update this edittext value that is coming from listview. Please anyone tell me how to do this?

< Intent intent = getIntent();
name = intent.getStringExtra("Name");
desg = intent.getStringExtra("Designation");

nam= (EditText)findViewById(R.id.NameEditText);
des= (EditText)findViewById(R.id.desgEditText);

nam.setText(name);
des.setText(desg);


insertButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String employeename =nameEditText.getText().toString();
int employeeno =Integer.parseInt(noEditText.getText().toString());
String designation =desgEditText.getText().toString();

dbhelper.insertIntoEmployeeTable(employeename, designation, employeeno);
Log.v("Emp_Name", employeename);
Log.v("Emp_no", String.valueOf(employeeno));
Log.v("Emp_Desg", designation);
Toast.makeText(getBaseContext(), "Your data is inserted",Toast.LENGTH_SHORT).show();
}
});
updateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String employeename =nam.getText().toString();
int employeeno =Integer.parseInt(noEditText.getText().toString());
String designation =des.getText().toString();

dbhelper.updateIntoEmployeeTable(employeename, designation, employeeno);
Log.v("updateEmp_Name", employeename);
Log.v("updateEmp_no", String.valueOf(employeeno));
Log.v("updateEmp_Desg", designation);
Toast.makeText(getBaseContext(), "Your data is updated",Toast.LENGTH_SHORT).show();


}
});
displayButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,GridViewActivity.class);
startActivity(i);//start gridview activity to show the records.
}
});
public void updateEmployeeTable(String employeename, String designation, int employeeno){
open();
ContentValues newValues = new ContentValues();
Log.v("UpdateEmployee", employeename + " " + " " + designation);

newValues.put("fld_employeename", employeename);
newValues.put("fld_designation", designation);
newValues.put("fld_employeeno", employeeno);

int update = db.update("tbl_employee", newValues,null, null);
db.close();
Log.v("Update_Query", String.valueOf(update));
}

ArrayList

推荐答案


这篇关于更新listview单行并再次显示在该列表视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-13 18:01