Editable ListView Items

I want to edit my items ListView

. eg; I have an item ListView

that I clicked on this item and add string value

using edit text

after that, I click on that item again and add a new one string value

next to the previous one string value

and again again again. When I click this item, I want to edit this list. How do I do it?

Java Source Package:

public class MainActivity extends Activity {
    TextView tvDers;
    EditText etDers, etDersSaati;
    EditText etNot;
    LinearLayout LayoutDers;
    ArrayAdapter<String> adapter;
    ListView list;
    protected void onCreate(Bundle savedInstanceState) {

        Button btnDersEkle = (Button) findViewById(R.id.btnDersEkle);

        list = (ListView) findViewById(R.id.listView1);
        adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1);
        etDers = new EditText(MainActivity.this);
        AlertDialog.Builder build = new AlertDialog.Builder(MainActivity.this);
        build.setTitle("Ders Ekle");

        build.setPositiveButton("Tamam", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
        final AlertDialog alertDers = build.create();

        btnDersEkle.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {





source to share

1 answer

Storing the values ​​of elements in the Collection order. Install this collection to the adapter. Add and remove these values ​​after the call notifyDataSetChanged

for the adapter.

Try it.

listView.setOnItemClickListener(new OnItemClickListener(){

    public void onItemClick(AdapterView<?> parent, View view, int position, long id){
         String item = (String) parent.getItemAtPosition(int position);
         item += "YourText";
         ArrayAdapter adapter = (ArrayAdapter ) parent.getAdapter();
         adapter.insert(item, position);


Sorry, but now I cannot verify this code. Therefore, I cannot say for sure that this is correct. Try different options and you will get it.

UPDATE In the clickListener dialog, you can try this:

public void onClick(DialogInterface dialog, int which) {
      ArrayAdapter adapter = (ArrayAdapter ) listView.getAdapter();
      String item = (String) listView.getSelectedItem();
      item += "YourText";

     adapter.insert(item, position);




All Articles