We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package com.example.todolist;
import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import androidx.appcompat.app.AppCompatActivity; import java.util.ArrayList;
public class MainActivity extends AppCompatActivity { private ArrayList taskList; private ArrayAdapter adapter;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // عناصر الشاشة ListView listView = findViewById(R.id.task_list); EditText inputTask = findViewById(R.id.input_task); Button addButton = findViewById(R.id.add_button); // إعداد قائمة المهام taskList = new ArrayList<>(); adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, taskList); listView.setAdapter(adapter); // زر إضافة مهمة addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String task = inputTask.getText().toString().trim(); if (!task.isEmpty()) { taskList.add(task); adapter.notifyDataSetChanged(); inputTask.setText(""); // إفراغ الحقل } } }); // حذف مهمة عند الضغط عليها listView.setOnItemClickListener((parent, view, position, id) -> { taskList.remove(position); adapter.notifyDataSetChanged(); }); }
}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
package com.example.todolist;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
private ArrayList taskList;
private ArrayAdapter adapter;
}
The text was updated successfully, but these errors were encountered: