I have a ListView , i made a custom_row for the items in the list , each row contains 2 TextView`s named (textView1 and textView2) and a ImageView, when i click on a item , a AlertDialog appears that has a input text there and OK , Cancel buttons.
After entering something in the input of alertdialog and clicking ok i want to modify textView2 from the item in the ListView i clicked.
How can i do that?
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
TextView tv=new TextView(getApplicationContext());
//Log.i("da","Clicked : "+labelData[position]);
setLabel(labelData[position]);
tv=(TextView)findViewById(R.id.textView2);
tv.setText("das");
}
public void setLabel(String poz){
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle("Set "+poz);
alertDialog.setMessage("Enter "+poz);
final EditText input = new EditText(this);
alertDialog.setView(input);
alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
Log.i("da","Clicked : "+value);
}
});
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});
alertDialog.show();
}
On Click Ok You get
Stringfrom Edittext(in Your Case input) And alsoPosition.Now Just set String in your Array I mean Remove old String Which you Used in setText in Your textview2.And add this.Then adapter.notifyDatasetChanged();.You should use Dynamic array to remove or add String value from Alert .I mean…